A powerful development framework for creating custom tools that interact with large language models using the Model Context Protocol (MCP). This framework provides a comprehensive toolset to extend the functionality of the Cursor IDE, enabling advanced features like web content retrieval and file processing (PDF, Word, Excel).
The Model Context Protocol Development Framework is designed to simplify the creation of tools that interact with large language models. It offers a modular and extensible architecture, making it easy to add new functionalities and integrate with existing systems.
The file
tool automatically identifies file types and selects the appropriate processing method. Supported formats include PDF, Word, and Excel.
file /path/to/document
file_path
- The local path to the fileThe pdf
tool processes PDF documents with two modes:
pdf /path/to/document.pdf [mode]
file_path
- The local path to the PDF filemode
- Processing mode (optional):quick
- Quick preview mode, extracts text onlyfull
- Full parsing mode, extracts text and images (default)The word
tool parses Word documents to extract text, tables, and images.
word /path/to/document.docx
file_path
- The local path to the Word documentThe excel
tool parses Excel files to provide complete table data and structure information.
excel /path/to/spreadsheet.xlsx
file_path
- The local path to the Excel fileThe url
tool retrieves content from any web page.
url https://example.com
url
- The URL of the website to retrieve content fromThe framework is modular and easy to maintain:
mcp_tool/
├── tools/
│ ├── __init__.py # Defines tool base classes and registries
│ ├── loader.py # Tool loader, automatically loads all tools
│ ├── file_tool.py # Comprehensive file processing tool
│ ├── pdf_tool.py # PDF parsing tool
│ ├── word_tool.py # Word document parsing tool
│ ├── excel_tool.py # Excel file processing tool
│ └── url_tool.py # URL tool implementation
├── __init__.py
├── __main__.py
└── server.py # MCP server implementation
tools
directory, e.g., your_tool.py
BaseTool
@ToolRegistry.register
decoratorexecute
method for the toolimport mcp.types as types
from . import BaseTool, ToolRegistry
@ToolRegistry.register
class YourTool(BaseTool):
"""Your tool description"""
name = "your_tool_name" # Unique identifier for the tool
description = "Your tool description" # Description displayed to users
input_schema = {
"type": "object",
"required": ["param1"], # Required parameters
"properties": {
"param1": {
"type": "string",
"description": "Description of parameter 1",
},
"param2": {
"type": "integer",
"description": "Description of parameter 2 (optional)",
}
},
}
async def execute(self, arguments: dict) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
"""Execute tool logic"""
# Parameter validation
if "param1" not in arguments:
return [types.TextContent(
type="text",
text="Error: Missing required argument 'param1'"
)]
# Get parameters
param1 = arguments["param1"]
param2 = arguments.get("param2", 0) # Get optional parameter with default value
# Execute tool logic
result = f"Processed parameters: {param1}, {param2}"
# Return result
return [types.TextContent(
type="text",
text=result
)]
# Clone the repository
git clone https://github.com/your-username/mcp-framework.git
cd mcp-framework
# Create environment file
cp .env.example .env
# Build and start
docker compose up --build -d
# View logs
docker compose logs -f
# Manage containers
docker compose ps
docker compose pause
docker compose unpause
docker compose down
Access the Service:
SSE endpoint: http://localhost:8000/sse
Cursor IDE Configuration:
Settings → Features → Add MCP Server
http://localhost:8000/sse
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y poppler-utils tesseract-ocr tesseract-ocr-chi-sim
# macOS
brew install poppler tesseract tesseract-lang
# Windows
# 1. Download and install Tesseract: https://github.com/UB-Mannheim/tesseract/wiki
# 2. Add Tesseract to the system PATH
# Create a virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
.\venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
python -m mcp_tool
Configure in the .env
file:
MCP_SERVER_PORT
: Server port (default: 8000)MCP_SERVER_HOST
: Binding address (default: 0.0.0.0)DEBUG
: Debug mode (default: false)MCP_USER_AGENT
: Custom User-AgentMain dependencies:
mcp
: Model Context Protocol implementationPyMuPDF
: PDF document processingpython-docx
: Word document processingpandas
and openpyxl
: Excel file processinghttpx
: Asynchronous HTTP clientanyio
: Asynchronous I/O supportclick
: Command-line interfacegit checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.