Spaces:
Runtime error
Runtime error
apple muncy
commited on
Commit
·
a7d3bec
1
Parent(s):
3b2afe5
initial push
Browse filesSigned-off-by: apple muncy <[email protected]>
- .gitignore +1 -0
- README.md +2 -1
- app.py +35 -0
- requirements.txt +3 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
client.py
|
README.md
CHANGED
@@ -5,8 +5,9 @@ colorFrom: red
|
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.35.0
|
|
|
8 |
app_file: app.py
|
9 |
-
pinned:
|
10 |
license: gpl-3.0
|
11 |
short_description: An example of an mcp server to use FastMCP along with Gradio
|
12 |
---
|
|
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.35.0
|
8 |
+
python_version: 3.11.2
|
9 |
app_file: app.py
|
10 |
+
pinned: true
|
11 |
license: gpl-3.0
|
12 |
short_description: An example of an mcp server to use FastMCP along with Gradio
|
13 |
---
|
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from mcp.server.fastmcp import FastMCP
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
mcp = FastMCP(
|
5 |
+
name = "Test FastMCP Server",
|
6 |
+
instructions="This server allows testing of tools",
|
7 |
+
)
|
8 |
+
# Implement your server's tools
|
9 |
+
@mcp.tool()
|
10 |
+
async def example_tool(param1: str, param2: int) -> str:
|
11 |
+
"""An example tool that demonstrates MCP functionality.
|
12 |
+
|
13 |
+
Args:
|
14 |
+
param1: First parameter description
|
15 |
+
param2: Second parameter description
|
16 |
+
|
17 |
+
Returns:
|
18 |
+
A string result from the tool execution
|
19 |
+
"""
|
20 |
+
# Tool implementation
|
21 |
+
result = f"Processed {param1} with value {param2}"
|
22 |
+
return result
|
23 |
+
|
24 |
+
@mcp.resource("file://documents/{name}")
|
25 |
+
def read_document(name: str) -> str:
|
26 |
+
"""Read a document by name."""
|
27 |
+
# This would normally read from disk
|
28 |
+
return f"Content of {name}"
|
29 |
+
|
30 |
+
@mcp.prompt(title="Code Review")
|
31 |
+
def review_code(code: str) -> str:
|
32 |
+
return f"Please review this code:\n\n{code}"
|
33 |
+
|
34 |
+
if __name__=="__main__":
|
35 |
+
mcp.run(transport="streamable-http",)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
mcp==1.10.1
|
2 |
+
mcp[cli]
|
3 |
+
|