Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe where logging info should be observed #171

Closed
sheffler opened this issue Jan 24, 2025 · 2 comments
Closed

Describe where logging info should be observed #171

sheffler opened this issue Jan 24, 2025 · 2 comments

Comments

@sheffler
Copy link
Contributor

I am examining the Context .info(), .debug() and report_progress() methods. I would like a simple example of how to use them and where I should look for output.

I have written the following tiny example. The Error output from the Inspector is shown ad the end of this message. Where should I be able to find the messages or progress? An example of the correct way to use these facilities would be appreciated.

Could there be an error where the send_log_message() method is not awaited?

from mcp.server.fastmcp import FastMCP, Context
import time

mcp = FastMCP("Tom2 Server 2024-01-23", debug=True, log_level="DEBUG")

@mcp.tool()
async def my_tool(x: float, y:float, ctx:Context) -> str:
    """Perform a long running calculation"""

    ctx.info(f"Processing Message 1")
    await ctx.report_progress(1, 2)
    time.sleep(2)
    ctx.debug(f"Processing Message 2")
    await ctx.report_progress(2, 2)
    time.sleep(2)
    return x*y

Error Output from the inspector.

[01/24/25 15:32:26] DEBUG Using selector: selector_events.py:59 KqueueSelector
DEBUG Received message: server.py:428 root=InitializedNotification(method=' notifications/initialized', params=None, jsonrpc='2.0')
[01/24/25 15:32:31] DEBUG Received message: server.py:428 <mcp.shared.session.RequestResponder object at 0x106d86080>
INFO Processing request of type server.py:432 ListToolsRequest
DEBUG Dispatching request of type server.py:437 ListToolsRequest
DEBUG Response sent server.py:475
[01/24/25 15:32:35] DEBUG Received message: server.py:428 <mcp.shared.session.RequestResponder object at 0x106d87f40>
INFO Processing request of type server.py:432 CallToolRequest
DEBUG Dispatching request of type server.py:437 CallToolRequest
[01/24/25 15:32:39] DEBUG Response sent server.py:475
INFO Warning: RuntimeWarning: coroutine server.py:495 'ServerSession.send_log_message' was never awaited
@VikashLoomba
Copy link

+1, experiencing this as well.

@dsp-ant dsp-ant closed this as completed Jan 27, 2025
@dsp-ant
Copy link
Member

dsp-ant commented Jan 27, 2025

fixed in #172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants