Update server.py
Browse files
server.py
CHANGED
|
@@ -3,7 +3,7 @@ import uvicorn
|
|
| 3 |
|
| 4 |
from mcp.server.fastmcp import FastMCP
|
| 5 |
from starlette.requests import Request
|
| 6 |
-
from starlette.responses import
|
| 7 |
|
| 8 |
from langchain_community.utilities import SQLDatabase
|
| 9 |
from langchain_community.tools.sql_database.tool import QuerySQLCheckerTool
|
|
@@ -19,19 +19,23 @@ llm = ChatOpenAI(
|
|
| 19 |
# Create an MCP server
|
| 20 |
mcp = FastMCP("Credit Card Database Server")
|
| 21 |
|
| 22 |
-
|
| 23 |
credit_card_db = SQLDatabase.from_uri(r"sqlite:///data/ccms.db")
|
| 24 |
query_checker_tool = QuerySQLCheckerTool(db=credit_card_db, llm=llm)
|
| 25 |
|
|
|
|
| 26 |
@mcp.custom_route("/", methods=["GET"])
|
| 27 |
-
async def home(request: Request) ->
|
| 28 |
-
return
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
@mcp.tool()
|
| 37 |
def sql_db_list_tables():
|
|
|
|
| 3 |
|
| 4 |
from mcp.server.fastmcp import FastMCP
|
| 5 |
from starlette.requests import Request
|
| 6 |
+
from starlette.responses import PlainTextResponse, Response
|
| 7 |
|
| 8 |
from langchain_community.utilities import SQLDatabase
|
| 9 |
from langchain_community.tools.sql_database.tool import QuerySQLCheckerTool
|
|
|
|
| 19 |
# Create an MCP server
|
| 20 |
mcp = FastMCP("Credit Card Database Server")
|
| 21 |
|
|
|
|
| 22 |
credit_card_db = SQLDatabase.from_uri(r"sqlite:///data/ccms.db")
|
| 23 |
query_checker_tool = QuerySQLCheckerTool(db=credit_card_db, llm=llm)
|
| 24 |
|
| 25 |
+
|
| 26 |
@mcp.custom_route("/", methods=["GET"])
|
| 27 |
+
async def home(request: Request) -> PlainTextResponse:
|
| 28 |
+
return PlainTextResponse(
|
| 29 |
+
"Credit Card Database Server"
|
| 30 |
+
"\n----\n"
|
| 31 |
+
"This server gives you access to the following tools:" \
|
| 32 |
+
"\n----\n" \
|
| 33 |
+
"sql_db_list_tables\n" \
|
| 34 |
+
"sql_db_schema\n" \
|
| 35 |
+
"sql_db_query_checker\n" \
|
| 36 |
+
"sql_db_query"
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
|
| 40 |
@mcp.tool()
|
| 41 |
def sql_db_list_tables():
|