Skip to content

Add resource Link #974

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

Merged
merged 3 commits into from
Jun 17, 2025
Merged

Add resource Link #974

merged 3 commits into from
Jun 17, 2025

Conversation

ihrpr
Copy link
Contributor

@ihrpr ihrpr commented Jun 17, 2025

Details: modelcontextprotocol/modelcontextprotocol#603
Closes #944


  • Added resource link to the tool output types
  • Added a test to integrations tests

@ihrpr ihrpr requested a review from bhosmer-ant June 17, 2025 18:18
bhosmer-ant
bhosmer-ant previously approved these changes Jun 17, 2025
Copy link
Contributor

@bhosmer-ant bhosmer-ant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline comment re Content/ContentBlock, but your call

src/mcp/types.py Outdated
ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource
"""A content block that can be used in prompts and tool results."""

Content = ContentBlock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is to reduce blast radius for the PR, but if so, should we maybe leave it named Content and then do the Content -> ContentBlock change in a followup, rather than having both names floating around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add deprecated!



class PromptMessage(BaseModel):
"""Describes a message returned as part of a prompt."""

role: Role
content: Content
content: ContentBlock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per above comment

@@ -859,7 +872,7 @@ class CallToolRequest(Request[CallToolRequestParams, Literal["tools/call"]]):
class CallToolResult(Result):
"""The server's response to a tool call."""

content: list[Content]
content: list[ContentBlock]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per above comment

"""A content block that can be used in prompts and tool results."""

Content: TypeAlias = ContentBlock
# """DEPRECATED: Content is deprecated, you should use ContentBlock directly."""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving content just in case someone uses it from SDK and not to break them

@bhosmer-ant bhosmer-ant self-requested a review June 17, 2025 19:17
Copy link
Contributor

@bhosmer-ant bhosmer-ant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bhosmer-ant
Copy link
Contributor

test failure looks like a linux flake?

[gw3] linux -- Python 3.11.12 /home/runner/work/python-sdk/python-sdk/.venv/bin/python

    @pytest.mark.anyio
    async def test_messages_are_executed_concurrently():
        server = FastMCP("test")
    
        @server.tool("sleep")
        async def sleep_tool():
            await anyio.sleep(_sleep_time_seconds)
            return "done"
    
        @server.resource(_resource_name)
        async def slow_resource():
            await anyio.sleep(_sleep_time_seconds)
            return "slow"
    
        async with create_session(server._mcp_server) as client_session:
            start_time = anyio.current_time()
            async with anyio.create_task_group() as tg:
                for _ in range(10):
                    tg.start_soon(client_session.call_tool, "sleep")
                    tg.start_soon(client_session.read_resource, AnyUrl(_resource_name))
    
            end_time = anyio.current_time()
    
            duration = end_time - start_time
>           assert duration < 10 * _sleep_time_seconds
E           assert 0.10288924399999644 < (10 * 0.01)

@ihrpr ihrpr merged commit d0443a1 into main Jun 17, 2025
20 of 21 checks passed
@ihrpr ihrpr deleted the ihrpr/resource-link branch June 17, 2025 19:23
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

Successfully merging this pull request may close these issues.

Add ResourceLink to CallToolResult
2 participants