Skip to main content

Seamlessly integrate MCP Registry servers into your LangChain workflows

Project description

๐Ÿ”— 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_mcp_registry-0.1.4.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_mcp_registry-0.1.4-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_mcp_registry-0.1.4.tar.gz.

File metadata

  • Download URL: langchain_mcp_registry-0.1.4.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for langchain_mcp_registry-0.1.4.tar.gz
Algorithm Hash digest
SHA256 87227d4443535cbd3762cf88bb567de26a12bcd8b4908eb47f8d2007d9e51ac5
MD5 12d9f055346219825a6f1d12ec012776
BLAKE2b-256 4108ae6377f8d5233cb8771ca5bb2d293b9dfc67d19307b1806623d1e4b839df

See more details on using hashes here.

File details

Details for the file langchain_mcp_registry-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_mcp_registry-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b1c8c43cf1cd0d293c976ecbf3aed7a40442307bbb76ba844649e11bf3ece4a7
MD5 7fecaa121bf24d2286b9f96a859db49d
BLAKE2b-256 c3d63a94ed7d6f9b1a52934212d2d7e30edd8483f7eb294106219551d5c952bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page