Skip to content

Fix MCP server support using MCPStreamableHTTPTool#4

Open
Copilot wants to merge 3 commits intomainfrom
copilot/improve-mcp-server-support
Open

Fix MCP server support using MCPStreamableHTTPTool#4
Copilot wants to merge 3 commits intomainfrom
copilot/improve-mcp-server-support

Conversation

Copy link

Copilot AI commented Dec 14, 2025

The commented-out MCP server code used a non-existent agent.add_mcp_server() method. Updated to use the correct MCPStreamableHTTPTool class for remote HTTP-based MCP servers with real-world examples.

Changes

  • Import: Added MCPStreamableHTTPTool from agent_framework
  • Tool creation: Replaced invalid add_mcp_server() calls with proper MCPStreamableHTTPTool instantiation
  • Real-world examples: Added two practical MCP server examples:
    • Microsoft Learn MCP server (HTTP)
    • GitHub MCP server (HTTP with OAuth)
  • Simplified usage pattern: Users uncomment the async context manager line and the tools=mcp_tool parameter (no code duplication)
  • Documentation: Added "Using MCP Servers" section to README with step-by-step setup instructions

Examples

Microsoft Learn MCP server:

mcp_tool = MCPStreamableHTTPTool(
    name="learn-mcp",
    url="https://learn.microsoft.com/mcp",
    description="Microsoft Learn MCP server"
)

GitHub MCP server with OAuth:

mcp_tool = MCPStreamableHTTPTool(
    name="github-mcp",
    url="https://api.github.com/mcp",
    headers={"Authorization": f"Bearer {os.getenv('GITHUB_TOKEN')}"},
    description="GitHub MCP server"
)

Usage:

# Uncomment these lines to enable MCP tools:
async with mcp_tool:
    agent = ChatAgent(
        chat_client=chat_client,
        instructions=instructions,
        tools=mcp_tool  # Uncomment this parameter
    )
    result = await agent.run("Your message")

This follows the official Agent Framework pattern for remote MCP servers over HTTP/SSE.

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve MCP server support</issue_title>
<issue_description>There is a commented out section of code showing optional ability to run the agent with MCP server tools passed in. It is not correct.

Please update this sample in simplest possible way to enable remote MCP servers to pass in their tools to the agent. use the learn example from this document: https://learn.microsoft.com/en-us/agent-framework/user-guide/model-context-protocol/using-mcp-tools?pivots=programming-language-python
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: paulyuk <1968137+paulyuk@users.noreply.github.com>
Copilot AI changed the title [WIP] Update agent to support remote MCP server tools Fix MCP server support using MCPStreamableHTTPTool Dec 14, 2025
Copilot AI requested a review from paulyuk December 14, 2025 09:21
@paulyuk
Copy link
Owner

paulyuk commented Dec 14, 2025

@copilot The optional code repeats too much of the while True: loop. Can't we just have the user uncomment the line with tools=mcp_tool?

Also, use two real examples of servers and tools to add:

  • Microsoft Learn MCP (http)
  • GitHub MCP (http using oauth)

Co-authored-by: paulyuk <1968137+paulyuk@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 14, 2025

@copilot The optional code repeats too much of the while True: loop. Can't we just have the user uncomment the line with tools=mcp_tool?

Also, use two real examples of servers and tools to add:...

Simplified the code to avoid repeating the while loop. Users now just uncomment two lines: the async with mcp_tool: line and the , tools=mcp_tool parameter.

Updated with two real examples:

  • Microsoft Learn MCP server (HTTP)
  • GitHub MCP server (HTTP with OAuth using GITHUB_TOKEN env var)

Changes in commit 782e755.

@paulyuk paulyuk marked this pull request as ready for review December 14, 2025 09:32
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.

Improve MCP server support

2 participants