Jinsong Li
Project description
mcp-adapter
- 对mcp sdk的二次封装
- 以python类继承的方式,非侵入式封装function到mcp tool的转化
- FastAPI支持,快速挂载在FastAPI服务中
Getting started
1. 继承McpServerAdapterBase,实现功能
from mcp_adapter.core.server_base import McpServerAdapterBase
class MockMcpServerSse(McpServerAdapterBase):
name = 'MockMcpServerSse'
description = 'MockMcpServerSse Service'
@staticmethod
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
@staticmethod
def sub(a: int, b: int) -> int:
"""Sub two numbers"""
return a - b
@staticmethod
def multiply(a: int, b: int) -> int:
"""Multiply two numbers"""
return a * b
class MockMcpServerHttpStreamable(McpServerAdapterBase):
name = 'MockMcpServerHttpStreamable'
description = 'MockMcpServerHttpStreamable Service'
@staticmethod
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
@staticmethod
def sub(a: int, b: int) -> int:
"""Sub two numbers"""
return a - b
@staticmethod
def multiply(a: int, b: int) -> int:
"""Multiply two numbers"""
return a * b
2. 在FastAPI项目中加载mcp server
请参考: 脚手架项目
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mcp_adapter-0.0.2.tar.gz
(3.8 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 mcp_adapter-0.0.2.tar.gz.
File metadata
- Download URL: mcp_adapter-0.0.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e76e9a4303ba722d371e0846ed5c562865f0e619f75951be76f6fdda1d03cf40
|
|
| MD5 |
2e0073dc0bdd2aefecd28cef09a61183
|
|
| BLAKE2b-256 |
935f8a297556c35c03e530bfd58eaab120e2c82e5b8862bc1621c740c3dfd391
|
File details
Details for the file mcp_adapter-0.0.2-py3-none-any.whl.
File metadata
- Download URL: mcp_adapter-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32db3c88faee7842d5e47ea5e02444728695e0f54d68662efa9e88b65dc0a8e5
|
|
| MD5 |
65fcb97614d48327247999c66fa5476c
|
|
| BLAKE2b-256 |
17c1aa7724fa23edf68360f1835c8e4d3c6d33bd3b19232f217fbaca1b2b9e71
|