Incident Agent
A Python FastMCP server for incident management and analysis, providing tools for greeting, echo, and server information retrieval.
README
Incident Agent
A Python FastMCP (Model Context Protocol) server for incident management and analysis.
This project provides a complete MCP server implementation with tools for greeting, echo functionality, and server information retrieval. It demonstrates the FastMCP framework capabilities and serves as a foundation for building more complex incident management tools.
Prerequisites
- Python 3.13+
- uv package manager
Setup
-
Clone the repository
git clone https://github.com/JayLiuMLP/incident-agent.git cd incident-agent -
Install dependencies
uv sync -
Verify installation
uv run python -c "import fastmcp; print('FastMCP installed successfully!')"
MCP Server Usage
Available Tools
The server provides the following MCP tools:
- hello - Greet a person or the world
- echo - Echo back a message
- server_info - Get server information and status
Available Resources
- config://server/info - Server configuration information
Starting the MCP Server
-
Standard MCP Server (stdio transport)
uv run fastmcp run main.py -
HTTP Server (for API access)
uv run fastmcp run main.py --transport http --port 8000 -
Inspect Server Configuration
uv run fastmcp inspect main.py
Testing the MCP Server
Method 1: Python Client (Recommended)
Use the built-in Python client utilities for easy testing:
# Run complete test suite (recommended)
uv run python mcp_client_utils.py
# Run comprehensive HTTP client test
uv run python http_client_test.py
Method 2: Using in Your Python Code
import asyncio
from mcp_client_utils import MCPClient, say_hello, echo_message
# Using utility functions
async def example():
greeting = await say_hello("Developer")
echo_result = await echo_message("Test message")
print(f"Greeting: {greeting}")
print(f"Echo: {echo_result}")
# Using client class
async def advanced_example():
client = MCPClient("http://localhost:8000/mcp")
tools = await client.list_tools()
server_info = await client.get_server_info()
print(f"Available tools: {tools}")
print(f"Server version: {server_info['version']}")
# Run the examples
asyncio.run(example())
asyncio.run(advanced_example())
Method 3: Integration with MCP Clients
The server can be integrated with MCP-compatible clients like Claude Desktop by adding to your configuration:
{
"mcpServers": {
"incident-agent": {
"command": "uv",
"args": ["run", "fastmcp", "run", "main.py"],
"cwd": "/path/to/incident-agent"
}
}
}
Method 4: HTTP API (curl)
⚠️ Note: HTTP API requires proper session management and is more complex. Python client is recommended.
For advanced users, you can use curl with the HTTP server:
# Start HTTP server first
uv run fastmcp run main.py --transport http --port 8000
# Test with Python client (much easier)
uv run python mcp_client_utils.py
Server Output Example
When running the test client, you should see:
🚀 MCP Client Tools Demo
Hello: Hello, Developer! 🌍 Welcome to the Incident Agent MCP Server!
Echo: Echo: This is a test message
Server status: running
Server version: 0.1.0
Available tools: ['hello', 'echo', 'server_info']
Development
-
Run the application
uv run python main.py -
Run tests
uv run pytest -
Setup pre-commit hooks
uv run pre-commit install -
Test MCP functionality
# Quick test uv run python mcp_client_utils.py
Quick Start
Want to test the MCP server right away? Follow these steps:
-
Install and setup (if not done already)
git clone https://github.com/JayLiuMLP/incident-agent.git cd incident-agent uv sync -
Start the HTTP server (in one terminal)
uv run fastmcp run main.py --transport http --port 8000 -
Test with Python client (in another terminal)
uv run python mcp_client_utils.py -
Expected output
🚀 MCP Client Tools Demo Hello: Hello, Developer! 🌍 Welcome to the Incident Agent MCP Server! Echo: Echo: This is a test message Server status: running Server version: 0.1.0 Available tools: ['hello', 'echo', 'server_info']
That's it! Your MCP server is working. 🎉
Project Structure
incident-agent/
├── main.py # Main MCP server entry point
├── run_server.py # Server demo script
├── mcp_client_utils.py # Primary Python client for testing (RECOMMENDED)
├── simple_client.py # Simple Python client example
├── http_client_test.py # Comprehensive HTTP client test
├── PYTHON_CLIENT_GUIDE.md # Detailed Python client usage guide
├── HELLO_WORLD_MCP.md # MCP server documentation
├── pyproject.toml # Project configuration and dependencies
├── .cursorrules # Development guidelines and best practices
└── src/incident_agent/ # Main application source
├── __init__.py # Package initialization
├── server/ # MCP server implementation
│ ├── __init__.py
│ └── server.py # FastMCP server definition
└── tools/ # MCP tools implementation
├── __init__.py
└── hello_tools.py # Hello world tools
Key Files
main.py- MCP server entry point, use withfastmcp runmcp_client_utils.py- RECOMMENDED Python client with utility functions and classes for testingsimple_client.py- Minimal client example for referencesrc/incident_agent/server/server.py- Core server implementationsrc/incident_agent/tools/hello_tools.py- Tool implementations
Troubleshooting
Common Issues
-
"Failed to connect to localhost" error
- Make sure the server is running:
uv run fastmcp run main.py --transport http --port 8000 - Check if port 8000 is available:
lsof -i :8000
- Make sure the server is running:
-
curl requests don't work
- Use Python client instead (recommended):
uv run python mcp_client_utils.py - HTTP API with curl requires complex session management
- Use Python client instead (recommended):
-
"No such file or directory" error
- Make sure you're in the project directory
- Run
uv syncto install dependencies
-
Import errors
- Ensure virtual environment is activated by using
uv runprefix - Check that FastMCP is installed:
uv run python -c "import fastmcp; print('OK')"
- Ensure virtual environment is activated by using
Getting Help
- Check
PYTHON_CLIENT_GUIDE.mdfor detailed client usage - Check
HELLO_WORLD_MCP.mdfor server implementation details - See
.cursorrulesfor development guidelines
Contributing
This project follows FastMCP development best practices. See .cursorrules for detailed development guidelines.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。