Repository navigation
MCP
weego edited this page May 28, 2026
·
1 revision
LightAgent can register tools from Model Context Protocol servers. It supports stdio and SSE transports through the mcp Python package.
MCP settings are passed as a dictionary with mcpServers:
mcp_settings = {
"mcpServers": {
"weather-stdio": {
"command": "python",
"args": ["./mcp/mcpServers/mcpServer_demo_stdio.py"],
"disabled": False,
},
"weather-sse": {
"url": "http://localhost:8000/sse",
"headers": {
"Authorization": "Bearer token",
},
"disabled": True,
},
}
}Set disabled to False for servers that should be connected.
setup_mcp() is async:
import asyncio
from LightAgent import LightAgent
agent = LightAgent(
model="gpt-4.1",
api_key="your_api_key",
base_url="https://api.openai.com/v1",
)
asyncio.run(agent.setup_mcp(mcp_setting=mcp_settings))
response = agent.run("Use the available MCP tools to check the weather.")
print(response)During setup, LightAgent lists tools from enabled MCP servers and adds them to the agent tool registry.
Use stdio for local MCP servers:
{
"command": "python",
"args": ["./mcp/mcpServers/mcpServer_demo_stdio.py"],
"env": {"SOME_KEY": "value"},
"disabled": False,
}Validate the command independently before connecting it to LightAgent.
Use SSE for remote or long-running MCP servers:
{
"url": "http://localhost:8000/sse",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer token",
},
"disabled": False,
}Confirm the SSE endpoint is reachable before debugging the agent layer.
- If no MCP tools appear, check
disabled, command paths, and server startup logs. - If a stdio server fails, run the command directly in a terminal.
- If an SSE server fails, test the endpoint and headers independently.
- If a tool call fails, check the MCP tool input schema and required arguments.
- Keep MCP server credentials out of committed files.
Reference files:
LightAgent Wiki - see the repository, releases, and issues.
- Home
- Quick Start
- Core Concepts
- API Reference
- Examples Cookbook
- Migration Guide
- Tools
- Tool Generator
- Memory
- MCP
- Skills
- LightFlow
- Tree of Thought
- Self-Learning
- Multi-Agent
- Tracing and Debugging
- Langfuse Observability
- Model Providers
- browser-use Integration
- Testing and CI
- Deployment Guide
- Architecture
- Security
- Known Limitations
- FAQ
- FAQ 中文
- Roadmap
- Release Process
- Contributing