mseep-fastapi-mcp-sse 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mseep_fastapi_mcp_sse-0.1.2.dist-info/METADATA +20 -0
- mseep_fastapi_mcp_sse-0.1.2.dist-info/RECORD +6 -0
- {mseep_fastapi_mcp_sse-0.1.0.dist-info → mseep_fastapi_mcp_sse-0.1.2.dist-info}/WHEEL +1 -1
- mseep_fastapi_mcp_sse-0.1.0.dist-info/METADATA +0 -200
- mseep_fastapi_mcp_sse-0.1.0.dist-info/RECORD +0 -6
- {mseep_fastapi_mcp_sse-0.1.0.dist-info → mseep_fastapi_mcp_sse-0.1.2.dist-info}/entry_points.txt +0 -0
- {mseep_fastapi_mcp_sse-0.1.0.dist-info → mseep_fastapi_mcp_sse-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {mseep_fastapi_mcp_sse-0.1.0.dist-info → mseep_fastapi_mcp_sse-0.1.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: mseep-fastapi-mcp-sse
|
3
|
+
Version: 0.1.2
|
4
|
+
Summary: A working example to create a FastAPI server with SSE-based MCP support
|
5
|
+
Home-page:
|
6
|
+
Author: mseep
|
7
|
+
Author-email: mseep <support@skydeck.ai>
|
8
|
+
Maintainer-email: mseep <support@skydeck.ai>
|
9
|
+
Requires-Python: >=3.6
|
10
|
+
Description-Content-Type: text/markdown
|
11
|
+
License-File: LICENSE
|
12
|
+
Requires-Dist: fastapi>=0.115.11
|
13
|
+
Requires-Dist: httpx>=0.28.1
|
14
|
+
Requires-Dist: mcp[cli]>=1.3.0
|
15
|
+
Requires-Dist: unicorn>=2.1.3
|
16
|
+
Dynamic: author
|
17
|
+
Dynamic: license-file
|
18
|
+
Dynamic: requires-python
|
19
|
+
|
20
|
+
# Package managed by MseeP.ai
|
@@ -0,0 +1,6 @@
|
|
1
|
+
mseep_fastapi_mcp_sse-0.1.2.dist-info/licenses/LICENSE,sha256=3jx_ovGaWR_Y9wL1s0njbZj7IyL5klS_5VvxO9EGbiE,1065
|
2
|
+
mseep_fastapi_mcp_sse-0.1.2.dist-info/METADATA,sha256=N9MQi6W4DKUFZ_q_k2x2mBVCsFuxk9OsZkkmGUpWdnU,560
|
3
|
+
mseep_fastapi_mcp_sse-0.1.2.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
4
|
+
mseep_fastapi_mcp_sse-0.1.2.dist-info/entry_points.txt,sha256=lWiP8hdv1rciwJn9kTxOBAVugY9fgMmwBgBVvp79EVg,37
|
5
|
+
mseep_fastapi_mcp_sse-0.1.2.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
6
|
+
mseep_fastapi_mcp_sse-0.1.2.dist-info/RECORD,,
|
@@ -1,200 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: mseep-fastapi-mcp-sse
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: A working example to create a FastAPI server with SSE-based MCP support
|
5
|
-
Home-page:
|
6
|
-
Author: mseep
|
7
|
-
Author-email: support@skydeck.ai
|
8
|
-
Requires-Python: >=3.6
|
9
|
-
Description-Content-Type: text/markdown
|
10
|
-
License-File: LICENSE
|
11
|
-
Requires-Dist: fastapi>=0.115.11
|
12
|
-
Requires-Dist: httpx>=0.28.1
|
13
|
-
Requires-Dist: mcp[cli]>=1.3.0
|
14
|
-
Requires-Dist: unicorn>=2.1.3
|
15
|
-
Dynamic: author
|
16
|
-
Dynamic: author-email
|
17
|
-
Dynamic: license-file
|
18
|
-
Dynamic: requires-python
|
19
|
-
|
20
|
-
# FastAPI MCP SSE
|
21
|
-
|
22
|
-
<p align="center">
|
23
|
-
<strong>English</strong> | <a href="/README.zh-CN.md">简体中文</a>
|
24
|
-
</p>
|
25
|
-
|
26
|
-
A Server-Sent Events (SSE) implementation using FastAPI framework with [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) integration.
|
27
|
-
|
28
|
-
## What is MCP?
|
29
|
-
|
30
|
-
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) is an open standard that enables AI models to interact with external tools and data sources. MCP solves several key challenges in AI development:
|
31
|
-
|
32
|
-
- **Context limitations**: Allows models to access up-to-date information beyond their training data
|
33
|
-
- **Tool integration**: Provides a standardized way for models to use external tools and APIs
|
34
|
-
- **Interoperability**: Creates a common interface between different AI models and tools
|
35
|
-
- **Extensibility**: Makes it easy to add new capabilities to AI systems without retraining
|
36
|
-
|
37
|
-
This project demonstrates how to implement MCP using Server-Sent Events (SSE) in a FastAPI web application.
|
38
|
-
|
39
|
-
## Description
|
40
|
-
|
41
|
-
This project demonstrates how to implement Server-Sent Events (SSE) using the FastAPI framework while integrating Model Context Protocol (MCP) functionality. The key feature is the seamless integration of MCP's SSE capabilities within a full-featured FastAPI web application that includes custom routes.
|
42
|
-
|
43
|
-
## Features
|
44
|
-
|
45
|
-
- Server-Sent Events (SSE) implementation with MCP
|
46
|
-
- FastAPI framework integration with custom routes
|
47
|
-
- Unified web application with both MCP and standard web endpoints
|
48
|
-
- Customizable route structure
|
49
|
-
- Clean separation of concerns between MCP and web functionality
|
50
|
-
|
51
|
-
## Architecture
|
52
|
-
|
53
|
-
This project showcases a modular architecture that:
|
54
|
-
|
55
|
-
1. Integrates MCP SSE endpoints (`/sse` and `/messages/`) into a FastAPI application
|
56
|
-
2. Provides standard web routes (`/`, `/about`, `/status`, `/docs`, `/redoc`)
|
57
|
-
3. Demonstrates how to maintain separation between MCP functionality and web routes
|
58
|
-
|
59
|
-
## Installation & Usage Options
|
60
|
-
|
61
|
-
### Prerequisites
|
62
|
-
|
63
|
-
Install [UV Package Manager](https://docs.astral.sh/uv/) - A fast Python package installer written in Rust:
|
64
|
-
|
65
|
-
```cmd
|
66
|
-
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
67
|
-
```
|
68
|
-
|
69
|
-
### Option 1: Quick Run Without Installation
|
70
|
-
|
71
|
-
Run the application directly without cloning the repository using UV's execution tool:
|
72
|
-
|
73
|
-
```cmd
|
74
|
-
uvx --from git+https://github.com/panz2018/fastapi_mcp_sse.git start
|
75
|
-
```
|
76
|
-
|
77
|
-
### Option 2: Full Installation
|
78
|
-
|
79
|
-
#### Create Virtual Environment
|
80
|
-
|
81
|
-
Create an isolated Python environment for the project:
|
82
|
-
|
83
|
-
```cmd
|
84
|
-
uv venv
|
85
|
-
```
|
86
|
-
|
87
|
-
#### Activate Virtual Environment
|
88
|
-
|
89
|
-
Activate the virtual environment to use it:
|
90
|
-
|
91
|
-
```cmd
|
92
|
-
.venv\Scripts\activate
|
93
|
-
```
|
94
|
-
|
95
|
-
#### Install Dependencies
|
96
|
-
|
97
|
-
Install all required packages:
|
98
|
-
|
99
|
-
```cmd
|
100
|
-
uv pip install -r pyproject.toml
|
101
|
-
```
|
102
|
-
|
103
|
-
#### Start the Integrated Server
|
104
|
-
|
105
|
-
Launch the integrated FastAPI server with MCP SSE functionality:
|
106
|
-
|
107
|
-
```cmd
|
108
|
-
python src/server.py
|
109
|
-
```
|
110
|
-
|
111
|
-
or
|
112
|
-
|
113
|
-
```cmd
|
114
|
-
uv run start
|
115
|
-
```
|
116
|
-
|
117
|
-
### Available Endpoints
|
118
|
-
|
119
|
-
After starting the server (using either Option 1 or Option 2), the following endpoints will be available:
|
120
|
-
|
121
|
-
- Main server: http://localhost:8000
|
122
|
-
- Standard web routes:
|
123
|
-
- Home page: http://localhost:8000/
|
124
|
-
- About page: http://localhost:8000/about
|
125
|
-
- Status API: http://localhost:8000/status
|
126
|
-
- Documentation (Swagger UI): http://localhost:8000/docs
|
127
|
-
- Documentation (ReDoc): http://localhost:8000/redoc
|
128
|
-
- MCP SSE endpoints:
|
129
|
-
- SSE endpoint: http://localhost:8000/sse
|
130
|
-
- Message posting: http://localhost:8000/messages/
|
131
|
-
|
132
|
-
### Debug with MCP Inspector
|
133
|
-
|
134
|
-
For testing and debugging MCP functionality, use the MCP Inspector:
|
135
|
-
|
136
|
-
```cmd
|
137
|
-
mcp dev ./src/weather.py
|
138
|
-
```
|
139
|
-
|
140
|
-
### Connect to MCP Inspector
|
141
|
-
|
142
|
-
1. Open MCP Inspector at http://localhost:5173
|
143
|
-
2. Configure the connection:
|
144
|
-
- Set Transport Type to `SSE`
|
145
|
-
- Enter URL: http://localhost:8000/sse
|
146
|
-
- Click `Connect`
|
147
|
-
|
148
|
-
### Test the Functions
|
149
|
-
|
150
|
-
1. Navigate to `Tools` section
|
151
|
-
2. Click `List Tools` to see available functions:
|
152
|
-
- `get_alerts` : Get weather alerts
|
153
|
-
- `get_forcast` : Get weather forecast
|
154
|
-
3. Select a function
|
155
|
-
4. Enter required parameters
|
156
|
-
5. Click `Run Tool` to execute
|
157
|
-
|
158
|
-
## Extending the Application
|
159
|
-
|
160
|
-
### Adding Custom Routes
|
161
|
-
|
162
|
-
The application structure makes it easy to add new routes using FastAPI's APIRouter:
|
163
|
-
|
164
|
-
1. Define new route handlers in routes.py using the APIRouter:
|
165
|
-
|
166
|
-
```python
|
167
|
-
@router.get("/new-route")
|
168
|
-
async def new_route():
|
169
|
-
return {"message": "This is a new route"}
|
170
|
-
```
|
171
|
-
|
172
|
-
2. All routes defined with the router will be automatically included in the main application
|
173
|
-
|
174
|
-
### Customizing MCP Integration
|
175
|
-
|
176
|
-
The MCP SSE functionality is integrated in server.py through:
|
177
|
-
|
178
|
-
- Creating an SSE transport
|
179
|
-
- Setting up an SSE handler
|
180
|
-
- Adding MCP routes to the FastAPI application
|
181
|
-
|
182
|
-
## Integration with [Continue](https://www.continue.dev/)
|
183
|
-
|
184
|
-
To use this MCP server with the Continue VS Code extension, add the following configuration to your Continue settings:
|
185
|
-
|
186
|
-
```json
|
187
|
-
{
|
188
|
-
"experimental": {
|
189
|
-
"modelContextProtocolServers": [
|
190
|
-
{
|
191
|
-
"transport": {
|
192
|
-
"name": "weather",
|
193
|
-
"type": "sse",
|
194
|
-
"url": "http://localhost:8000/sse"
|
195
|
-
}
|
196
|
-
}
|
197
|
-
]
|
198
|
-
}
|
199
|
-
}
|
200
|
-
```
|
@@ -1,6 +0,0 @@
|
|
1
|
-
mseep_fastapi_mcp_sse-0.1.0.dist-info/licenses/LICENSE,sha256=3jx_ovGaWR_Y9wL1s0njbZj7IyL5klS_5VvxO9EGbiE,1065
|
2
|
-
mseep_fastapi_mcp_sse-0.1.0.dist-info/METADATA,sha256=3wJcOSvv4ZVUKip85GxPfnsNYRZBI5_jIdtzIwX4eys,5591
|
3
|
-
mseep_fastapi_mcp_sse-0.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
4
|
-
mseep_fastapi_mcp_sse-0.1.0.dist-info/entry_points.txt,sha256=lWiP8hdv1rciwJn9kTxOBAVugY9fgMmwBgBVvp79EVg,37
|
5
|
-
mseep_fastapi_mcp_sse-0.1.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
6
|
-
mseep_fastapi_mcp_sse-0.1.0.dist-info/RECORD,,
|
{mseep_fastapi_mcp_sse-0.1.0.dist-info → mseep_fastapi_mcp_sse-0.1.2.dist-info}/entry_points.txt
RENAMED
File without changes
|
{mseep_fastapi_mcp_sse-0.1.0.dist-info → mseep_fastapi_mcp_sse-0.1.2.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{mseep_fastapi_mcp_sse-0.1.0.dist-info → mseep_fastapi_mcp_sse-0.1.2.dist-info}/top_level.txt
RENAMED
File without changes
|