MCP server for subnet calculations, IP validation, and OSPF wildcard mask generation
Project description
MCP Server template for better AI Coding
Inspired by MCP Official Tutorial
Overview
This template provides a streamlined foundation for building Model Context Protocol (MCP) servers in Python. It's designed to make AI-assisted development of MCP tools easier and more efficient.
Features
- Ready-to-use MCP server implementation
- Configurable transport modes (stdio, SSE)
- Example weather service integration (NWS API)
- Clean, well-documented code structure
- Minimal dependencies
- Embedded MCP specifications and documentation for improved AI tool understanding
Cursor Rules Integration
This project uses Cursor Rules for improved AI coding assistance, with patterns from Awesome Cursor Rules.
- Clean Code Guidelines: Built-in clean code rules help maintain consistency and quality
- Enhanced AI Understanding: Rules provide context that helps AI assistants generate better code
- Standardized Patterns: Follow established best practices for MCP server implementation
Cursor Rules help both AI coding assistants and human developers maintain high code quality standards and follow best practices.
Integrated MCP Documentation
This template includes comprehensive MCP documentation directly in the project:
-
Complete MCP Specification (
protocals/mcp.md): The full Model Context Protocol specification that defines how AI models can interact with external tools and resources. This helps AI assistants understand MCP concepts and implementation details without requiring external references. -
Python SDK Guide (
protocals/sdk.md): Detailed documentation for the MCP Python SDK, making it easier for AI tools to provide accurate code suggestions and understand the library's capabilities. -
Example Implementation (
protocals/example_weather.py): A practical weather service implementation demonstrating real-world MCP server patterns and best practices.
Having these resources embedded in the project enables AI coding assistants to better understand MCP concepts and provide more accurate, contextually relevant suggestions during development.
Requirements
- Python 3.12+
- Dependencies:
mcp>=1.4.1httpx>=0.28.1starlette>=0.46.1uvicorn>=0.34.0
Getting Started
Installation
-
Clone this repository:
git clone https://github.com/yourusername/mcp-server-python-template.git cd mcp-server-python-template
-
Create a virtual environment and install dependencies:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -e .
Running the Example Server
The template includes a weather service example that demonstrates how to build MCP tools:
# Run with stdio transport (for CLI tools)
python server.py --transport stdio
# Run with SSE transport (for web applications)
python server.py --transport sse --host 0.0.0.0 --port 8080
Creating Your Own MCP Tools
To create your own MCP tools:
-
Import the necessary components from
mcp:from mcp.server.fastmcp import FastMCP
-
Initialize your MCP server with a namespace:
mcp = FastMCP("your-namespace")
-
Define your tools using the
@mcp.tool()decorator:@mcp.tool() async def your_tool_function(param1: str, param2: int) -> str: """ Your tool description. Args: param1: Description of param1 param2: Description of param2 # Subnet Calculator MCP Server A Model Context Protocol (MCP) server that provides subnet calculation, IP validation, and OSPF wildcard mask generation for AI assistants. ## Features - 🔢 Calculate subnet information from host requirements - 🌐 Generate OSPF wildcard masks - ✅ Validate IP addresses within subnets - 🔄 Reverse subnet calculations from masks - ⚡ Sub-100 ms response times - 💯 100% accuracy on subnet math (verified through unit tests) ## Installation ### Option 1: Use with uvx (No Installation Required) ```bash uvx subnet-calculator-mcp ``` ### Option 2: Install Permanently ```bash uv tool install subnet-calculator-mcp ``` ## Usage with Claude Desktop Add the server to your Claude Desktop configuration. **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json` **Windows:** `%APPDATA%\Claude\claude_desktop_config.json` ```json { "mcpServers": { "subnet-calculator": { "command": "uvx", "args": ["subnet-calculator-mcp"] } } } ``` If you installed the package with `uv tool install`, update the command to `"subnet-calculator-mcp"` and remove `args`. ## Available Tools - **calculate_subnet** – Derive full subnet details from a base IP and host requirement. - **calculate_wildcard_mask** – Generate wildcard masks and optional OSPF statements. - **validate_ip_in_subnet** – Confirm IP membership and deliver subnet insights. - **calculate_subnet_from_mask** – Reverse engineer network information from an IP and mask. - **get_nth_usable_ip** – Retrieve the Nth usable host address quickly. ## Development ```bash # Clone the repository git clone https://github.com/yourusername/subnet-calculator-mcp cd subnet-calculator-mcp # Install dependencies uv sync # Run tests uv run pytest # Build package uv build ``` ## License MIT License – see `LICENSE` for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file subnet_calculator_mcp-0.1.0.tar.gz.
File metadata
- Download URL: subnet_calculator_mcp-0.1.0.tar.gz
- Upload date:
- Size: 105.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c0823af5b21e4e81e361b71723e1a5f1705a0f6ba3a8bc5360943722ecd8f4c
|
|
| MD5 |
8102e5f87ea20c79e499f9d36d8bbff8
|
|
| BLAKE2b-256 |
ef293576f4c65a672a9f9618b5af58b632ed30029ef964c0baec8eec267ab4be
|
File details
Details for the file subnet_calculator_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: subnet_calculator_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
218801613f4aaccf50ef7368923b78dc196051492cc49ba7c25cd8dfdf3896aa
|
|
| MD5 |
fb3f092c815f1d8de96a1de138c3ee74
|
|
| BLAKE2b-256 |
1e8af1e255e545324346518e6b18ac470d63b257df5ea7e45477aea8b1e05a72
|