mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: MCP sample bugbash fixes (#4001)
* MCP sample bugbash fixes * import fix
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# Copyright (c) Microsoft. All rights reserved.
|
# Copyright (c) Microsoft. All rights reserved.
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from agent_framework import Agent, MCPStreamableHTTPTool
|
from agent_framework import Agent, MCPStreamableHTTPTool
|
||||||
@@ -54,3 +55,7 @@ async def api_key_auth_example() -> None:
|
|||||||
print(f"User: {query}")
|
print(f"User: {query}")
|
||||||
result = await agent.run(query)
|
result = await agent.run(query)
|
||||||
print(f"Agent: {result.text}")
|
print(f"Agent: {result.text}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(api_key_auth_example())
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ async def github_mcp_example() -> None:
|
|||||||
# Set approval_mode="never_require" to allow the MCP tool to execute without approval
|
# Set approval_mode="never_require" to allow the MCP tool to execute without approval
|
||||||
client = OpenAIResponsesClient()
|
client = OpenAIResponsesClient()
|
||||||
github_mcp_tool = client.get_mcp_tool(
|
github_mcp_tool = client.get_mcp_tool(
|
||||||
server_label="GitHub",
|
name="GitHub",
|
||||||
server_url="https://api.githubcopilot.com/mcp/",
|
url="https://api.githubcopilot.com/mcp/",
|
||||||
headers=auth_headers,
|
headers=auth_headers,
|
||||||
require_approval="never",
|
approval_mode="never_require",
|
||||||
)
|
)
|
||||||
|
|
||||||
# 5. Create agent with the GitHub MCP tool
|
# 5. Create agent with the GitHub MCP tool
|
||||||
|
|||||||
Reference in New Issue
Block a user