GitHub MCP agent
Read GitHub issues, pull requests, and repository activity through GitHub's hosted MCP server.
Connect an agent to the official GitHub MCP server. This example uses its hosted read-only endpoint and a GitHub personal access token.
import asyncio
import os
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.mcp import MCPTools
async def main() -> None:
async with MCPTools(
url="https://api.githubcopilot.com/mcp/readonly",
transport="streamable-http",
headers={"Authorization": f"Bearer {os.environ['GITHUB_TOKEN']}"},
) as github_tools:
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
tools=[github_tools],
instructions="Summarize repository activity and link the issues or pull requests you used.",
markdown=True,
)
await agent.aprint_response(
"Summarize recent issues and pull requests in agno-agi/agno.",
stream=True,
)
if __name__ == "__main__":
asyncio.run(main())Prerequisites
Create and activate a Python environment. Install the dependencies and set the keys:
uv pip install -U "agno[mcp,openai]"
export GITHUB_TOKEN="your_github_personal_access_token"
export OPENAI_API_KEY="your_openai_api_key"Grant the GitHub token read access to the repositories and resources you intend to query, including any required organization authorization. GitHub's remote-server guide documents hosted access and available toolsets. Its /readonly endpoint restricts the exposed tools to read operations.
Save the code as github_agent.py, then run:
python github_agent.pyThe former @modelcontextprotocol/server-github npm recipe is archived. Its legacy source remains available for existing integrations; use the maintained GitHub server for new setups.