MCP Server Example
A simple Python-based MCP (Model Context Protocol) Server that demonstrates the basic capabilities of an MCP server.
Features
This MCP server provides:
Tools
- greeting: Generate personalized greetings with different styles
- calculator: Perform basic arithmetic operations (add, subtract, multiply, divide)
Resources
- sample://users: A list of sample user data
- sample://products: A list of sample product data
Prompts
- code_review: Generate code review checklists for different programming languages and complexity levels
Installation
From PyPI
pip install mcp-server-poc-rahmac
From Source
git clone https://github.com/rahmac/mcp_poc.git
cd mcp_poc
pip install -e .
Development Installation
git clone https://github.com/rahmac/mcp_poc.git
cd mcp_poc
pip install -e ".[dev]"
Usage
Running the Server
The server can be run directly:
mcp-server-poc-rahmac
Or using Python:
python -m mcp_server_poc_rahmac.server
Using with MCP Clients
This server implements the MCP protocol and can be used with any MCP-compatible client. The server communicates via stdio.
Example Configuration
For MCP clients that use configuration files:
{
"servers": {
"example": {
"command": "mcp-server-poc-rahmac",
"args": []
}
}
}
API Reference
Tools
greeting
Generate a personalized greeting.
Parameters:
name(string, required): The name of the person to greetgreeting_type(string, optional): Type of greeting - "hello", "hi", or "howdy" (default: "hello")
Example:
{
"name": "greeting",
"arguments": {
"name": "Alice",
"greeting_type": "hi"
}
}
calculator
Perform basic arithmetic operations.
Parameters:
operation(string, required): The operation - "add", "subtract", "multiply", or "divide"a(number, required): First numberb(number, required): Second number
Example:
{
"name": "calculator",
"arguments": {
"operation": "add",
"a": 5,
"b": 3
}
}
Resources
sample://users
Returns a JSON array of sample user objects with id, name, and email fields.
sample://products
Returns a JSON array of sample product objects with id, name, and price fields.
Prompts
code_review
Generate a code review checklist.
Parameters:
language(string, required): Programming languagecomplexity(string, optional): Complexity level - "basic", "intermediate", or "advanced" (default: "intermediate")
Development
Setting up Development Environment
# Clone the repository
git clone https://github.com/rahmac/mcp_poc.git
cd mcp_poc
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
Running Tests
pytest
Code Formatting
# Format code
black src/ tests/
# Sort imports
isort src/ tests/
# Type checking
mypy src/
Building for PyPI
# Build the package
python -m build
# Upload to PyPI (requires credentials)
twine upload dist/*
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run the test suite
- Submit a pull request
Changelog
0.1.0 (2024-06-10)
- Initial release
- Basic MCP server implementation
- Greeting and calculator tools
- Sample resources
- Code review prompt
Metadata
Release files for mcp-server-poc-rahmac 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mcp_server_poc_rahmac-0.1.2.tar.gz | 5.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_server_poc_rahmac-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.9 kB
Release files / mcp_server_poc_rahmac-0.1.2.tar.gz
| Download URL | mcp_server_poc_rahmac-0.1.2.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67c520d57bd5baea38636b44a82c3fed3f3e8d1abd948781f0300556afeaad8e
|
|
BLAKE2b-256 checksum How to use checksums |
f3e56f48c630ef81b06a4d21030daced73c21c40ff174b989abc03a7851c7da3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|
Release files / mcp_server_poc_rahmac-0.1.2-py3-none-any.whl
| Download URL | mcp_server_poc_rahmac-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6beba7f39f94af7da3955addbb21d0138d24b186e2d1a92171a4550be60b8639
|
|
BLAKE2b-256 checksum How to use checksums |
0405fe374cc743d1ad9964f116e89ca5456b3daca54f4908fbc6a8f912a4061f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|
Security for mcp-server-poc-rahmac 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.