- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.7k
Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
Summary
The MCP Python SDK's HttpResource class lacks token isolation mechanisms when making requests to external APIs, violating the MCP specification requirement that "MCP servers MUST NOT pass through the token it received from the MCP client to upstream APIs."
🎯 Core Problem
MCP specification
If the MCP server makes requests to upstream APIs, it may act as an OAuth client to them. The access token used at the upstream API is a separate token, issued by the upstream authorization server. The MCP server MUST NOT pass through the token it received from the MCP client.
HttpResource Lacks Token Isolation
File Location: src/mcp/server/fastmcp/resources/types.py:148-159
class HttpResource(Resource):
    """A resource that reads from an HTTP endpoint."""
    url: str = Field(description="URL to fetch content from")
    mime_type: str = Field(default="application/json", description="MIME type of the resource content")
    async def read(self) -> str | bytes:
        """Read the HTTP content."""
        async with httpx.AsyncClient() as client:
            response = await client.get(self.url)  # ⚠️ No authentication headers!
            response.raise_for_status()
            return response.textProblem Analysis
- Lacks Authentication Mechanism: HttpResourcemakes direct calls to external APIs without any authentication headers
- Lacks Token Isolation Checks: No mechanism to prevent passing client tokens
🔍 Security Impact
- Lack of framework-level protection against token passthrough
- Developers may incorrectly pass client tokens
P.S. I am not entirely certain if this is the correct location where the upstream API calling issue occurs. If I have misunderstood the implementation or missed other relevant code paths, I would greatly welcome and appreciate discussion and clarification from the maintainers.
Example Code
Python & MCP Python SDK
latest