matsuap commited on
Commit
08dd397
·
1 Parent(s): 7e1b5c1

初回コミットに基づくファイルの追加

Browse files
Files changed (4) hide show
  1. .gitignore +2 -0
  2. Dockerfile +17 -0
  3. app.py +32 -0
  4. requirements.txt +1 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .venv/
2
+ __pycache__/
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ # Set the working directory
4
+ WORKDIR /app
5
+
6
+ # Copy the requirements file and install dependencies
7
+ COPY requirements.txt .
8
+ RUN pip install --no-cache-dir -r requirements.txt
9
+
10
+ # Copy the application code
11
+ COPY app.py .
12
+
13
+ # Expose the port the app runs on
14
+ EXPOSE 7860
15
+
16
+ # Command to run the application
17
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # server.py
2
+ from fastmcp import FastMCP
3
+
4
+ mcp = FastMCP("Demo 🚀")
5
+
6
+ @mcp.tool()
7
+ def hello(name: str) -> str:
8
+ return f"Hello, {name}!"
9
+
10
+ @mcp.tool()
11
+ def multiply(a: float, b: float) -> float:
12
+ """Multiplies two numbers."""
13
+ return a * b
14
+
15
+ # Static resource
16
+ @mcp.resource("config://version")
17
+ def get_version():
18
+ return "2.0.1"
19
+
20
+ # Dynamic resource template
21
+ @mcp.resource("users://{user_id}/profile")
22
+ def get_profile(user_id: int):
23
+ # Fetch profile for user_id...
24
+ return {"name": f"User {user_id}", "status": "active"}
25
+
26
+ @mcp.prompt()
27
+ def summarize_request(text: str) -> str:
28
+ """Generate a prompt asking for a summary."""
29
+ return f"Please summarize the following text:\n\n{text}"
30
+
31
+ if __name__ == "__main__":
32
+ mcp.run(transport="sse", host="0.0.0.0", port=7860)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastmcp