Loomal

GitHub MCP server in LangChain tools for your agent, in code.

LangChain has no config file for MCP — you wire servers up in code with langchain-mcp-adapters. Here's how to load GitHub's hosted MCP server into a LangChain agent in a dozen lines of Python.

Unlike desktop MCP clients, LangChain doesn't read a settings file — MCP servers are declared in your application code via the langchain-mcp-adapters package, which converts a server's MCP tools into LangChain tool objects any agent can use.

GitHub's official MCP server (github/github-mcp-server, 30.6k stars) is a hosted remote endpoint, which suits LangChain deployments well: nothing extra to ship in your container, just an HTTP connection with a token.

Why GitHub tools inside a LangChain agent

The server exposes repository management, issue triage, PR operations, and Actions inspection as MCP tools. Inside a LangChain agent that unlocks programmatic workflows desktop clients can't do — a scheduled agent that summarizes the week's merged PRs, a support bot that files reproducible bug reports as issues, a CI assistant that reads failing workflow logs and proposes fixes.

The full set of tools the server publishes is visible on its Loomal listing at https://loomal.ai/marketplace/github — worth scanning before you decide which tools to expose to your agent.

Install the adapter and connect

Install the bridge package with pip install langchain-mcp-adapters (it lives alongside langchain and langgraph). Then instantiate MultiServerMCPClient with the GitHub endpoint over the streamable_http transport, passing your PAT as a header:

agent.py
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent

client = MultiServerMCPClient({
    "github": {
        "transport": "streamable_http",
        "url": "https://api.githubcopilot.com/mcp/",
        "headers": {"Authorization": "Bearer ghp_YOUR_GITHUB_PAT"},
    }
})

tools = await client.get_tools()
agent = create_react_agent("anthropic:claude-sonnet-4-5", tools)

Keep the token out of the code

In anything beyond a notebook, read the PAT from an environment variable or secrets manager and interpolate it into the headers dict. Use a fine-grained token scoped to the repositories and permissions the agent genuinely needs — an unattended LangChain agent with a broad classic PAT is a standing incident waiting to happen.

If different agents need different access levels, mint separate tokens per agent rather than sharing one; revocation then maps cleanly to a single workload.

Trim the tool list

get_tools() returns everything the server offers, which can be dozens of tools — more than most agents need and enough to dilute tool selection quality. Filter the list before building the agent: keep the issue and PR tools for a triage bot, drop the rest. Smaller tool sets measurably improve an LLM's tool-choice accuracy.

Tool schemas come through as standard LangChain tools, so you can also wrap them with your own validation or logging before handing them to the agent.

Debugging without a settings UI

There's no status dot here — failures surface as exceptions. An HTTP 401 from get_tools() means the Authorization header is wrong (check the Bearer prefix and token validity). A connection or protocol error usually means the URL lost its trailing slash or the transport string isn't exactly streamable_http.

Remember the client methods are async; calling get_tools() outside an event loop raises immediately. In scripts, wrap your entry point with asyncio.run().

FAQ

How do I use the GitHub MCP server with LangChain?

Install langchain-mcp-adapters, create a MultiServerMCPClient with the server's URL (https://api.githubcopilot.com/mcp/), transport streamable_http, and an Authorization header with your PAT. Call get_tools() and pass the result to your agent constructor.

Is there a config file like other MCP clients use?

No — LangChain declares MCP servers in code. The dict you pass to MultiServerMCPClient plays the role that mcp.json plays in editors, which has an upside: configuration lives in version control and deploys with your app.

Can I connect to more than just GitHub?

Yes, that's what the Multi in MultiServerMCPClient means. Add more named entries to the same dict — a filesystem server over stdio, a search server over HTTP — and get_tools() returns the combined toolset for your agent.

Why does get_tools() hang or raise in my script?

The adapter API is async, so it must run inside an event loop — use asyncio.run(main()) in scripts. If it raises an HTTP error instead, it's auth or URL: verify the token, the Bearer prefix, and the trailing slash on /mcp/.

More MCP servers for LangChain agents.

Find servers with live-probed tool lists on the Loomal marketplace.

Browse the marketplace