|
| 1 | +import importlib.resources |
| 2 | + |
| 3 | +from cratedb_about.instruction import GeneralInstructions |
1 | 4 | from fastmcp import FastMCP |
2 | 5 | from fastmcp.tools import Tool |
3 | 6 |
|
|
10 | 13 | query_sql, |
11 | 14 | ) |
12 | 15 |
|
13 | | -# Create FastMCP application object. |
14 | | -mcp: FastMCP = FastMCP(__appname__) |
15 | | - |
| 16 | +instructions_general = GeneralInstructions().render() |
| 17 | +instructions_mcp = (importlib.resources.files("cratedb_mcp") / "instructions.md").read_text() |
16 | 18 |
|
17 | | -# ------------------------------------------ |
18 | | -# Health / Status |
19 | | -# ------------------------------------------ |
20 | | -mcp.add_tool( |
21 | | - Tool.from_function( |
22 | | - fn=get_cluster_health, |
23 | | - description="Return the health of the CrateDB cluster.", |
24 | | - tags={"health", "monitoring", "status"}, |
25 | | - ) |
| 19 | +# Create FastMCP application object. |
| 20 | +mcp: FastMCP = FastMCP( |
| 21 | + name=__appname__, |
| 22 | + instructions=instructions_mcp + instructions_general, |
26 | 23 | ) |
27 | 24 |
|
28 | 25 |
|
|
31 | 28 | # ------------------------------------------ |
32 | 29 | mcp.add_tool( |
33 | 30 | Tool.from_function( |
34 | | - fn=query_sql, |
35 | | - description="Send an SQL query to CrateDB. Only 'SELECT' queries are allowed.", |
| 31 | + fn=get_table_metadata, |
| 32 | + description="Return column schema and metadata for all tables stored in CrateDB. " |
| 33 | + "Use it to inquire entities you don't know about.", |
36 | 34 | tags={"text-to-sql"}, |
37 | 35 | ) |
38 | 36 | ) |
39 | 37 | mcp.add_tool( |
40 | 38 | Tool.from_function( |
41 | | - fn=get_table_metadata, |
42 | | - description="Return an aggregation of all CrateDB's schema, tables and their metadata.", |
| 39 | + fn=query_sql, |
| 40 | + description="Send an SQL query to CrateDB and return results. " |
| 41 | + "Only 'SELECT' queries are allowed.", |
43 | 42 | tags={"text-to-sql"}, |
44 | 43 | ) |
45 | 44 | ) |
|
64 | 63 | tags={"documentation"}, |
65 | 64 | ) |
66 | 65 | ) |
| 66 | + |
| 67 | + |
| 68 | +# ------------------------------------------ |
| 69 | +# Health / Status |
| 70 | +# ------------------------------------------ |
| 71 | +mcp.add_tool( |
| 72 | + Tool.from_function( |
| 73 | + fn=get_cluster_health, |
| 74 | + description="Return the health of the CrateDB cluster.", |
| 75 | + tags={"health", "monitoring", "status"}, |
| 76 | + ) |
| 77 | +) |
0 commit comments