Add your description here
Project description
MCP-YNU - FastMCP Server
A dynamic MCP server implementation using FastMCP that automatically loads tools, resources, and prompts from respective directories.
Features
- Dynamic loading of modules from
tools/,resources/, andprompts/directories - Automatic discovery and registration of modules
- Simple configuration and extensibility
- Type hints for better code clarity and static analysis
- Comprehensive logging for monitoring server activity
Recent Updates
- Added type hints throughout the codebase
- Improved MCP instance handling
- Added logging functionality
- Added MIT license
- Updated documentation with reference links
Directory Structure
mcp-ynu/
├── tools/ # Directory for tool modules
│ ├── __init__.py
│ ├── example.py
├── resources/ # Directory for resource modules
│ ├── __init__.py
│ ├── example.py
├── prompts/ # Directory for prompt modules
│ ├── __init__.py
│ ├── example.py
├── logger.py # Logger implementation
├── main.py # Main implementation
├── mcp_server.py # MCP server implementation
├── README.md # Project documentation
├── LICENSE # MIT License
└── pyproject.toml # Project configuration
Usage
- Create modules in the appropriate directories
- Import mcp via
from mcp_server import mcp - Run the server:
python main.py
Example Modules
Tools Module Example (tools/example.py)
from mcp_server import mcp
import httpx
@mcp.tool()
def calculate_bmi(weight_kg: float, height_m: float) -> float:
"""Calculate BMI given weight in kg and height in meters"""
return weight_kg / (height_m**2)
@mcp.tool()
async def fetch_weather(city: str) -> str:
"""Fetch current weather for a city"""
async with httpx.AsyncClient() as client:
response = await client.get(f"https://api.weather.com/{city}")
return response.text
Resources Module Example (resources/example.py)
from mcp_server import mcp
@mcp.resource("config://app")
def get_config() -> str:
"""Static configuration data"""
return "App configuration here"
@mcp.resource("users://{user_id}/profile")
def get_user_profile(user_id: str) -> str:
"""Dynamic user data"""
return f"Profile data for user {user_id}"
Prompts Module Example (prompts/example.py)
from mcp_server import mcp
from mcp.server.fastmcp.prompts import base
@mcp.prompt()
def review_code(code: str) -> str:
return f"Please review this code:\n\n{code}"
@mcp.prompt()
def debug_error(error: str) -> list[base.Message]:
return [
base.UserMessage("I'm seeing this error:"),
base.UserMessage(error),
base.AssistantMessage("I'll help debug that. What have you tried so far?"),
]
Debugging
- Update
MCP_TRANSPORT_TYPEin.env, Executepython main.pyto start the mcp server - Execute
npx @modelcontextprotocol/inspectorto open the inspect. - Choose
SSETransport Type with URLhttp://localhost:<mcp_server_port>/sseor ChooseSTDIOTransport Type with Commandpythonand Arguments/path/to/main.py
Requirements
- Python >= 3.10
- FastMCP
Reference Links
License
This project is licensed under the MIT License - see the LICENSE file 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
mseep_mcp_ynu-0.1.1.tar.gz
(6.2 kB
view details)
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 mseep_mcp_ynu-0.1.1.tar.gz.
File metadata
- Download URL: mseep_mcp_ynu-0.1.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
698a72868e00f8596b26062303ab881cba53ad631ca2927db567bd1e222bc424
|
|
| MD5 |
d1b465a40c29d4868cc030bc41ae59c6
|
|
| BLAKE2b-256 |
e7c80699bb0982207951000e6121d5710a1510e864e1e64cfb084454f0a96f0c
|
File details
Details for the file mseep_mcp_ynu-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mseep_mcp_ynu-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3894fb06cf59f400b0c57d39a62fb8381e08b37d94ed56edcdeda9fb94433182
|
|
| MD5 |
56cb75ab8f78f2fe436a3f449f010420
|
|
| BLAKE2b-256 |
f0c012f56ee57853c8b3d3a610f0c840b7d84499c39805de150cda1513695a59
|