Metadata-Version: 2.4
Name: langchain-mcp-registry
Version: 0.1.1
Summary: Seamlessly integrate MCP Registry servers into your LangChain workflows
Project-URL: Homepage, https://github.com/ChangjunZhao/langchain-mcp-registry
Project-URL: Repository, https://github.com/ChangjunZhao/langchain-mcp-registry
Project-URL: Issues, https://github.com/ChangjunZhao/langchain-mcp-registry/issues
Author-email: Foresee Sira AI Team <dev@foresee.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,ai,langchain,mcp,model-context-protocol,registry,tools
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: aiofiles>=23.0.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: langchain-mcp-adapters>=0.1.0
Requires-Dist: platformdirs>=4.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: typer[all]>=0.12.0
Provides-Extra: dev
Requires-Dist: black>=24.0.0; extra == 'dev'
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pre-commit>=3.6.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.3.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5.0; extra == 'docs'
Requires-Dist: mkdocs>=1.5.0; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == 'docs'
Description-Content-Type: text/markdown

# 🔗 LangChain MCP Registry

> Seamlessly integrate MCP Registry servers into your LangChain workflows

[![PyPI version](https://badge.fury.io/py/langchain-mcp-registry.svg)](https://badge.fury.io/py/langchain-mcp-registry)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)

## 🌟 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

```bash
pip install langchain-mcp-registry
```

### Python API

```python
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

```bash
# 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

```python
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

```python
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

```python
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

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

### Error Handling

```python
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

```python
# 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](CONTRIBUTING.md) for details.

## 📄 License

MIT License - see [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- [Model Context Protocol](https://modelcontextprotocol.io/)
- [LangChain](https://www.langchain.com/)
- [Anthropic](https://www.anthropic.com/)

## 🔗 Links

- **PyPI**: https://pypi.org/project/langchain-mcp-registry/
- **GitHub**: https://github.com/ChangjunZhao/langchain-mcp-registry
- **Issues**: https://github.com/ChangjunZhao/langchain-mcp-registry/issues

---

Made with ❤️ for the LangChain and MCP communities
