Skip to main content

🔗 LangChain MCP Registry

Seamlessly integrate MCP Registry servers into your LangChain workflows

PyPI version License: MIT Python 3.11+

🌟 Features

  • 🔍 Automatic Discovery: Search and discover MCP servers from the official registry
  • 🔄 Seamless Integration: Convert registry servers to LangChain-compatible tools
  • 🚀 Zero Configuration: Works out of the box with sensible defaults
  • 🛡️ Type Safe: Full type hints and Pydantic models
  • 🎯 CLI & Python API: Use via command line or programmatically
  • 📦 Multiple Transports: Support for stdio, HTTP, SSE

🚀 Quick Start

Installation

pip install langchain-mcp-registry

Python API

from langchain_mcp_registry import MCPRegistryClient
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

# 1. Discover servers from registry
async with MCPRegistryClient() as client:
    servers = await client.search_servers(query="weather")

    # 2. Auto-convert to LangChain tools
    tools = await client.load_tools(servers[0])

    # 3. Use in LangChain agent
    llm = ChatOpenAI(model="gpt-4")
    agent = create_react_agent(llm, tools)

    result = await agent.ainvoke({
        "messages": [{"role": "user", "content": "What's the weather in SF?"}]
    })

CLI Usage

# Search for servers
mcp-registry search weather

# List server details
mcp-registry info @modelcontextprotocol/server-brave-search

# Install and test a server
mcp-registry install @modelcontextprotocol/server-brave-search
mcp-registry test brave-search "search for AI news"

📚 Documentation

Registry Client

from langchain_mcp_registry import MCPRegistryClient

client = MCPRegistryClient(
    registry_url="https://registry.modelcontextprotocol.io",
    timeout=30.0,
    cache_ttl=3600
)

# Search with filters
servers = await client.search_servers(
    query="github",
    limit=10,
    version="latest"
)

# Get server details
server_details = await client.get_server_details(
    name="@modelcontextprotocol/server-github",
    version="latest"
)

Configuration Converter

from langchain_mcp_registry import RegistryToMCPConverter

converter = RegistryToMCPConverter()

# Convert registry server to MCP config
mcp_config = converter.convert(registry_server)
# Output: {"command": "npx", "args": [...], "env": {...}}

# Validate configuration
is_valid = converter.validate_config(mcp_config)

Tool Loader

from langchain_mcp_registry import MCPToolLoader

loader = MCPToolLoader()

# Load tools from registry server
tools = await loader.load_from_registry(
    server_name="@modelcontextprotocol/server-everything",
    version="latest"
)

# Load multiple servers
all_tools = await loader.load_multiple([
    "server-brave-search",
    "server-github",
    "server-filesystem"
])

🏗️ Architecture

┌─────────────────────────────────────────────────────────┐
│                    LangChain Agent                      │
└────────────────────┬────────────────────────────────────┘
                     │
                     ▼
┌─────────────────────────────────────────────────────────┐
│              LangChain MCP Registry                     │
│  ┌──────────────┐  ┌────────────┐  ┌─────────────┐    │
│  │   Registry   │  │ Converter  │  │    Tool     │    │
│  │   Client     │─▶│  (R → M)   │─▶│   Loader    │    │
│  └──────────────┘  └────────────┘  └─────────────┘    │
└────────────────────┬────────────────────────────────────┘
                     │
                     ▼
┌─────────────────────────────────────────────────────────┐
│          MCP Registry (modelcontextprotocol.io)         │
└─────────────────────────────────────────────────────────┘

🔧 Advanced Usage

Custom Registry

client = MCPRegistryClient(
    registry_url="https://your-private-registry.com",
    headers={"Authorization": "Bearer YOUR_TOKEN"}
)

Error Handling

from langchain_mcp_registry.exceptions import (
    ServerNotFoundError,
    InvalidConfigError,
    RegistryConnectionError
)

try:
    tools = await client.load_tools("non-existent-server")
except ServerNotFoundError:
    print("Server not found in registry")
except InvalidConfigError as e:
    print(f"Invalid configuration: {e}")

Caching

# Enable local caching for faster repeated access
client = MCPRegistryClient(
    cache_enabled=True,
    cache_ttl=7200,  # 2 hours
    cache_dir="~/.mcp-registry-cache"
)

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

📄 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments

🔗 Links


Made with ❤️ for the LangChain and MCP communities

Metadata

Release files for langchain-mcp-registry 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-mcp-registry 0.1.4
File Size Uploaded
langchain_mcp_registry-0.1.4.tar.gz 41.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-mcp-registry 0.1.4
File Interpreter ABI Platform
langchain_mcp_registry-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 62.2 kB

Release files / langchain_mcp_registry-0.1.4.tar.gz

Download URL langchain_mcp_registry-0.1.4.tar.gz
Size 41.5 kB
Tags Source
SHA-256 checksum
How to use checksums
87227d4443535cbd3762cf88bb567de26a12bcd8b4908eb47f8d2007d9e51ac5
BLAKE2b-256 checksum
How to use checksums
4108ae6377f8d5233cb8771ca5bb2d293b9dfc67d19307b1806623d1e4b839df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / langchain_mcp_registry-0.1.4-py3-none-any.whl

Download URL langchain_mcp_registry-0.1.4-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1c8c43cf1cd0d293c976ecbf3aed7a40442307bbb76ba844649e11bf3ece4a7
BLAKE2b-256 checksum
How to use checksums
c3d63a94ed7d6f9b1a52934212d2d7e30edd8483f7eb294106219551d5c952bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page