
precisemcp
一个基于 MCP 协议的服务器应用示例,支持模块化设计和流式 HTTP 传输。
Repository Info
About This Server
一个基于 MCP 协议的服务器应用示例,支持模块化设计和流式 HTTP 传输。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
MCP Server Example
This repository contains an example of an MCP (Model Context Protocol) server application. It demonstrates how to build and use MCP tools and resources with a streamable HTTP transport.
🏗️ Project Structure
precisemcp/
├── server.py # Main server entry point (NEW - modular)
├── config.py # Configuration management
├── auth.py # JWT authentication utilities
├── data_processing.py # Patient data transformation
├── tools.py # MCP tools definitions
├── mcp_precise.py # Original monolithic server (still works)
├── mcp_utils.py # Utilities for the MCP server
├── test_client.py # Client for testing server tools
├── pyproject.toml # Dependencies
├── MCP_TOOLS_DOCUMENTATION.md # Complete tool documentation
├── MCP_TOOLS_QUICK_REFERENCE.md # Quick reference guide
├── REFACTORING_GUIDE.md # Modular structure guide
└── README.md # This file
🚀 Quick Start
Prerequisites
- Python 3.13+ (or 3.12+ should work)
uvpackage manager
Installation
-
Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh -
Add uv to your PATH permanently:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc -
Verify uv installation:
uv --version -
Install dependencies:
uv sync
🖥️ Running the Application
Option 1: Modular Server (Recommended)
Terminal 1 - Start the new modular server:
# Run on default port 8000
uv run python3 server.py
# Run on a custom port (e.g., 8001)
PORT=8001 uv run python3 server.py
Option 2: Original Monolithic Server
Terminal 1 - Start the original server:
# Run on default port 8000
uv run python3 mcp_precise.py
# Run on a custom port (e.g., 8001)
PORT=8001 uv run python3 mcp_precise.py
💡 Note: Both servers provide identical functionality. The modular version (
server.py) is recommended for better maintainability and development experience.
The server will print the exact URL it's running on.
Running the Test Client
Once the server is running, you can use the test client to verify the functionality of the tools.
Terminal 2 - Run Test Client:
uv run python3 test_client.py
📋 Documentation
📖 Complete Tool Documentation
- MCP Tools Documentation - Comprehensive documentation for all MCP tools
- Quick Reference Guide - Quick lookup table for tools and parameters
- Output Format Specification - 🎯 For integration: Exact response format and code examples
- Refactoring Guide - Details about the modular code organization
🔧 Available Tools (Summary)
The server exposes 10 MCP tools organized into categories:
| Category | Tools | Purpose |
|---|---|---|
| Patient Info | fetch_patient_info, fetch_patient_by_id, fetch_patient_by_phone, fetch_patient_by_name_and_doi | Patient data retrieval |
| Studies | fetch_study_details | Medical study information |
| Case Management | get_case_update_details, insert_case_update_log | Case tracking and updates |
| Reporting | get_patient_report | Patient reports |
| Billing | get_patient_lien_bill_balance | Patient billing and lien information |
| Tasks | get_patient_todo_status | Patient to-do items |
📚 Available Resources
| Resource | URI | Description |
|---|---|---|
| Greeting | hello://greeting | Server health check and greeting |
💡 For detailed tool documentation including parameters, return values, and examples, see MCP_TOOLS_DOCUMENTATION.md
🛠️ Development
Adding New Tools
To add a new tool to any server, use the @mcp.tool() decorator:
@mcp.tool()
async def your_new_tool(param1: str, param2: int) -> str:
"""Description of what your tool does.
Args:
param1: Description of parameter 1
param2: Description of parameter 2
"""
# Your tool logic here
return f"Result: {param1} {param2}"
Adding New Resources
To add a new resource:
@mcp.resource("your://resource/uri")
async def your_resource() -> str:
"""Description of your resource."""
return "Your resource content"
🌟 Benefits of an Independent Server
- Scalability: Multiple clients can connect simultaneously
- Deployment Flexibility: Server can run on different machines
- Production Ready: Better suited for real-world applications
- Resource Efficiency: No subprocess overhead
- Network Transparent: Works across network boundaries
- Stateless Options: Better for load balancing and cloud deployment
📦 Dependencies
mcp[cli]>=1.9.1- MCP framework with CLI toolsuvicorn- for running the server
🚀 Next Steps
- ✅ Real APIs: Integrated with RadFlow and Chatbot APIs
- ✅ Authentication: JWT and Basic auth implemented with caching
- ✅ Logging: Enhanced logging and monitoring implemented
- ✅ Error Handling: Robust error handling and recovery implemented
- ✅ Port Configuration: Environment variable support for custom ports
- ✅ Modular Architecture: Clean separation of concerns with multiple modules
- More Tools: Add database, file system, or calculation tools
- WebSocket Support: Add WebSocket transport option
- Load Balancing: Configure multiple server instances
- Testing Suite: Add comprehensive unit and integration tests
- Docker Support: Add containerization for easy deployment
- API Rate Limiting: Implement request rate limiting and throttling
📝 License
MIT License - Feel free to use this as a starting point for your own MCP projects!
Quick Start
Clone the repository
git clone https://github.com/pranavmodi/precisemcpInstall dependencies
cd precisemcp
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.