Jarisko commited on
Commit
7bc5725
·
1 Parent(s): 363d176

trying out fastmcp

Browse files
Files changed (3) hide show
  1. app.py +26 -9
  2. requirements.txt +1 -0
  3. test.ipynb +27 -0
app.py CHANGED
@@ -1,5 +1,28 @@
1
- import gradio as gr
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  def question(question: str) -> str:
4
  """
5
  Answers any question.
@@ -7,12 +30,6 @@ def question(question: str) -> str:
7
 
8
  return "42"
9
 
10
- app = gr.Interface(
11
- fn=question,
12
- inputs="text",
13
- outputs="text",
14
- title="Answer any question",
15
- description="Answer to the Ultimate Question of Life, the Universe, and Everything"
16
- )
17
 
18
- app.launch(mcp_server=True, share=True)
 
 
1
+ # import gradio as gr
2
 
3
+ # def question(question: str) -> str:
4
+ # """
5
+ # Answers any question.
6
+ # """
7
+
8
+ # return "42"
9
+
10
+ # app = gr.Interface(
11
+ # fn=question,
12
+ # inputs="text",
13
+ # outputs="text",
14
+ # title="Answer any question",
15
+ # description="Answer to the Ultimate Question of Life, the Universe, and Everything"
16
+ # )
17
+
18
+ # app.launch(mcp_server=True, share=True)
19
+
20
+ from mcp.server.fastmcp import FastMCP
21
+
22
+ mcp = FastMCP("test_mcp_server")
23
+
24
+
25
+ @mcp.tool()
26
  def question(question: str) -> str:
27
  """
28
  Answers any question.
 
30
 
31
  return "42"
32
 
 
 
 
 
 
 
 
33
 
34
+ if __name__ == "__main__":
35
+ mcp.run(transport="sse")
requirements.txt CHANGED
@@ -1 +1,2 @@
 
1
  gradio[mcp]
 
1
+ mcp[cli]
2
  gradio[mcp]
test.ipynb ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "9aa0f60f",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from mcp import MPC"
11
+ ]
12
+ }
13
+ ],
14
+ "metadata": {
15
+ "kernelspec": {
16
+ "display_name": ".venv",
17
+ "language": "python",
18
+ "name": "python3"
19
+ },
20
+ "language_info": {
21
+ "name": "python",
22
+ "version": "3.11.6"
23
+ }
24
+ },
25
+ "nbformat": 4,
26
+ "nbformat_minor": 5
27
+ }