python-mcp-server-client
支持查询主流agent框架技术文档的MCP server(支持stdio和sse两种传输协议), 支持 langchain、llama-index、autogen、agno、openai-agents-sdk、mcp-doc、camel-ai 和 crew-ai
GitHub Stars
135
User Rating
Not Rated
Favorites
0
Views
91
Forks
29
Issues
9
Installation
Difficulty
IntermediateEstimated Time
10-20 minutes
Requirements
Python 3.7以上UVの最新バージョンInstallation
Installation
Prerequisites
Python: 3.7 or higher
UV: Latest version
Installation Steps
1. Install UV Package
MacOS/Linux:bash
curl -LsSf https://astral.sh/uv/install.sh | sh
powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
2. Initialize Project
bash
Create project directory
uv init mcp-server
cd mcp-server
Create and activate virtual environment
uv venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
Install dependencies
uv add "mcp[cli]" httpx
Create server implementation file
touch main.py
Troubleshooting
Issue: Server won't start Solution: Check Python version and reinstall dependencies.Configuration
Configuration
Basic Configuration
Server Setup
Edit themain.py file to implement the MCP server. Here is a basic configuration example:
python
import json
import os
import httpx
from mcp import tool
async def search_web(query: str) -> dict | None:
payload = json.dumps({"q": query, "num": 3})
headers = {
"X-API-KEY": os.getenv("SERPER_API_KEY"),
"Content-Type": "application/json",
}
async with httpx.AsyncClient() as client:
response = await client.post(SERPER_URL, headers=headers, data=payload, timeout=30.0)
return response.json()
Environment Variables
Set the following environment variables as needed:bash
export SERPER_API_KEY="your-api-key"
Examples
Examples
Basic Usage
Here is a basic usage example for the MCP server:Programmatic Usage
python
import requests
import json
def call_mcp_tool(tool_name, params):
response = requests.post(
'http://localhost:3000/mcp/call',
json={
'tool': tool_name,
'parameters': params
}
)
return response.json()
Usage example
result = call_mcp_tool('analyze', {
'input': 'sample data',
'options': {'format': 'json'}
})
Use Cases
Projects that require unified API calls to AI models
Applications that integrate information from different data sources
Tools that perform data transformation or processing between AI frameworks
Automated data analysis or reporting systems
Additional Resources
Related MCPs
AIFoundry-MCPConnector-FabricGraphQL
10
This repository demonstrates the integration of an Azure OpenAI-powered AI agent with a Microsoft Fabric data warehouse using the Model Context Protocol (MCP). MCP enables dynamic discovery of tools and data resources, unifying their integration with AI agents. By leveraging GraphQL, it allows bidirectional access to enterprise data, enhancing the capabilities of AI agents.