đ Pure Agentic MCP Server
A pure implementation of the Model Context Protocol (MCP) with an agentic architecture. All features are exposed as MCP tools through specialized agents.
đ Quick Start
Prerequisites
- Python 3.11+
- Virtual environment support
Installation
git clone <repo-url>
cd mcp_server_full
python -m venv .venv
.venv\Scripts\activate
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
Configuration
Create a .env
file with your API keys (all optional):
# OpenAI Agent (optional)
OPENAI_API_KEY=your_openai_api_key_here
# Ollama Agent (optional, uses local Ollama server)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3.2
# File Agent (enabled by default, no config needed)
# Provides file reading, writing, and listing capabilities
Running the Server
For Claude Desktop (MCP Protocol)
python run_mcp_server.py
Add to your Claude Desktop config (claude_desktop_config.json
):
{
"mcpServers": {
"agentic-mcp": {
"command": "python",
"args": ["run_mcp_server.py"],
"cwd": "d:\\AI Lab\\MCP research\\mcp_server_full"
}
}
}
For Web Interface (HTTP + Streamlit)
python simple_mcp_host.py
streamlit run streamlit_app.py
Access the web interface at: http://localhost:8501
Testing Your Setup
python test_quick.py
python test_both.py
python validate_server.py
⨠Features
- đ¤ Pure Agentic Architecture: All capabilities (OpenAI, Ollama, File operations) are implemented as agents
- đ Dual Access Modes: MCP protocol for Claude Desktop + HTTP endpoints for web/Streamlit UI
- ⥠Dynamic Tool Registry: Agents register their tools automatically at startup
- đ§ Modular Design: Add new agents easily without modifying core server code
- đą Clean Web UI: Modern Streamlit interface for interactive tool usage
- đĄī¸ Graceful Degradation: Agents fail independently without affecting the system
- đ Environment-Based Config: Secure API key management via environment variables
đ Documentation
Architecture Overview
The server implements a pure agentic pattern where:
- Agents encapsulate specific functionality (OpenAI API, Ollama, file operations)
- Registry manages dynamic tool registration and routing
- MCP Server provides JSON - RPC protocol compliance for Claude Desktop
- HTTP Host exposes tools via REST API for web interfaces
- Streamlit UI provides user - friendly web access to all tools
Claude Desktop ââ MCP Protocol ââ Pure MCP Server ââ Agent Registry ââ Agents
â
Web Browser ââ HTTP API ââ Simple MCP Host ââ Agent Registry ââ Agents
Available Agents & Tools
đ¤ OpenAI Agent
Status: Available with API key
Tools:
openai_chat
: Chat completion with GPT models
openai_analysis
: Text analysis and insights
Setup: Add OPENAI_API_KEY
to .env
file
đĻ Ollama Agent
Status: Available with local Ollama server
Tools:
ollama_chat
: Chat with local Ollama models
ollama_generate
: Text generation
Setup: Install and run Ollama locally, configure OLLAMA_BASE_URL
and OLLAMA_MODEL
đ File Agent
Status: Always available
Tools:
file_read
: Read file contents
file_write
: Write content to files
file_list
: List directory contents
Setup: No configuration needed
API Usage
MCP Protocol (Claude Desktop)
Tools are automatically available in Claude Desktop once the server is configured. Ask Claude to:
- "Read the contents of file.txt"
- "Generate text using Ollama"
- "Analyze this text with OpenAI"
HTTP API (Web/Streamlit)
curl http://localhost:8000/tools
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{
"tool_name": "file_read",
"arguments": {
"file_path": "example.txt"
}
}'
Architecture
Core Components
pure_mcp_server.py
: Main MCP JSON - RPC server for Claude Desktop integration
simple_mcp_host.py
: HTTP wrapper that exposes MCP tools via REST API
registry.py
: Dynamic agent and tool registration system
run_mcp_server.py
: Entry point script for Claude Desktop configuration
config.py
: Environment - based configuration management
protocol.py
: MCP protocol models and types
Agents
agents/base.py
: Base agent interface that all agents implement
agents/openai_agent.py
: OpenAI API integration agent
agents/ollama_agent.py
: Local Ollama model integration agent
agents/file_agent.py
: File system operations agent
User Interfaces
streamlit_app.py
: Modern web UI for interactive tool usage
- Claude Desktop: Direct MCP protocol integration
Agent Registration Flow
class YourAgent(BaseAgent):
def get_tools(self) -> Dict[str, Any]:
return {
"your_tool": {
"description": "What your tool does",
"inputSchema": {...}
}
}
async def handle_tool_call(self, tool_name: str, params: Dict[str, Any]) -> Any:
pass
registry.register_agent("your_agent", YourAgent(config))
Development
Project Structure
mcp_server_full/
âââ agents/ # Agent implementations
â âââ base.py # Base agent interface
â âââ openai_agent.py # OpenAI integration
â âââ ollama_agent.py # Ollama integration
â âââ file_agent.py # File operations
âââ pure_mcp_server.py # Main MCP server for Claude Desktop
âââ simple_mcp_host.py # HTTP host for web interfaces
âââ registry.py # Dynamic tool registration
âââ run_mcp_server.py # Claude Desktop entry point
âââ streamlit_app.py # Web UI
âââ config.py # Configuration management
âââ protocol.py # MCP protocol models
âââ requirements.txt # Dependencies
âââ .env # Environment variables (create this)
âââ ADDING_NEW_AGENTS.md # Detailed agent development guide
âââ README.md # This file
Adding New Agents
For a complete step - by - step guide on adding new agents, see ADDING_NEW_AGENTS.md.
Quick Overview:
- Create agent file in
agents/
inheriting from BaseAgent
- Implement
get_tools()
and handle_tool_call()
methods
- Register agent in both
pure_mcp_server.py
and simple_mcp_host.py
- Add configuration and test your agent
The guide includes complete code examples, best practices, and troubleshooting tips.
Adding New Tools
To add new tools to existing agents:
- Edit the agent's
get_tools()
method to define new tool schema
- Add handler method in agent's
handle_tool_call()
method
- Test the new tool functionality
- Update documentation
Example:
def get_tools(self):
return {
"new_tool": {
"description": "Description of new tool",
"inputSchema": {
"type": "object",
"properties": {
"param": {"type": "string", "description": "Parameter description"}
},
"required": ["param"]
}
}
}
async def handle_tool_call(self, tool_name: str, params: Dict[str, Any]) -> Any:
if tool_name == "new_tool":
return await self._handle_new_tool(params)
Troubleshooting
Common Issues
- Agent Not Available: Check API keys and service connectivity
python test_quick.py
- Claude Desktop Not Connecting: Verify config path and entry point
# Check claude_desktop_config.json
{
"mcpServers": {
"agentic-mcp": {
"command": "python",
"args": ["run_mcp_server.py"],
"cwd": "d:\\AI Lab\\MCP research\\mcp_server_full"
}
}
}
- Streamlit UI Issues: Ensure HTTP host is running
python simple_mcp_host.py
streamlit run streamlit_app.py
- OpenAI Errors: Check API key and quota
python openai_test.py
- Ollama Not Working: Verify Ollama server is running
curl http://localhost:11434/api/tags
Debug Mode
Enable detailed logging:
export LOG_LEVEL=DEBUG
python run_mcp_server.py
Health Checks
curl http://localhost:8000/health
curl http://localhost:8000/tools
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{"tool_name": "file_list", "arguments": {"directory_path": "."}}'
Dependencies
Core Runtime
- pydantic: Configuration and data validation
- asyncio: Async operation support
- httpx: HTTP client for external APIs
- aiofiles: Async file operations
Agent - Specific
- openai: OpenAI API client (for OpenAI agent)
- ollama: Ollama API client (for Ollama agent)
Web Interface
- streamlit: Modern web UI framework
- requests: HTTP requests for Streamlit
Development & Testing
- pytest: Testing framework
- logging: Debug and monitoring
All dependencies are automatically installed via requirements.txt
.
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature
- Add your agent following the agent development guide
- Test your changes:
python test_quick.py
- Submit a pull request
Agent Development Workflow
- Plan: Define what tools your agent will provide
- Implement: Create agent class inheriting from
BaseAgent
- Register: Add agent registration to both server files
- Test: Verify agent works in both MCP and HTTP modes
- Document: Update README and create usage examples
đ License
MIT
đģ Streamlit Web Interface
Features
- đ§ Real - time Tool Discovery: Automatically displays all available tools from registered agents
- đŦ Interactive Interface: Easy - to - use forms for tool parameters
- đ Response Display: Formatted display of tool results
- đ Agent Status: Real - time monitoring of agent availability
- âī¸ Configuration: Environment - based setup with clear status indicators
Usage
- Start the backend:
python simple_mcp_host.py
- Launch Streamlit:
streamlit run streamlit_app.py
- Open browser: Navigate to http://localhost:8501
- Select tools: Choose from available agent tools
- Execute: Fill parameters and run tools interactively
Tool Integration
The Streamlit UI automatically discovers and creates forms for any tools registered by agents, making it easy to test and use new functionality as agents are added.