You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Step 2a: Auto-generate system tools from catalog tables
138
138
139
-
You can generate a suite of reusable data tools (Schema, Profile, Read, Search Summary, Search Content, Analyze) directly from catalog tables and their descriptions. This is helpful for quickly exposing exploratory and read/query capabilities to MCP.
139
+
You can generate a suite of reusable data tools (Schema, Profile, Read, Search Summary, Search Content, Analyze) directly from catalog tables and their descriptions. This is helpful for quickly exposing exploratory and read/query capabilities to MCP. Available tools include: - Schema: list columns/types for any or all tables - Profile: column statistics (counts, basic numeric analysis [min, max, mean, etc.], contextual information for text columns [average_length, etc.]) - Read: read a selection of rows from a single table. These rows can be paged over, filtered and can use column projections. - Search Summary: regex search across all text columns in all tables -- returns back dataframe names with result counts. - Search Content: regex search across a single table, specifying one or more text columns to search across -- returns back rows corresponding to the query. - Analyze: Write raw SQL to perform complex analysis on one or more tables.
140
140
141
141
Requirements:
142
142
@@ -147,15 +147,15 @@ Example:
147
147
```python
148
148
from fenic import Session
149
149
from fenic.api.mcp.server import create_mcp_server
150
-
from fenic.api.mcp.tools importToolGenerationConfig
"Show the schema (column names and types) for any or all of the datasets listed below. This call should be the first step in exploring the available datasets.",
"Read rows from a single dataset. Use to sample data, or to execute simple queries over the data that do not require filtering or grouping.",
97
95
"Use `include_columns` and `exclude_columns` to filter columns by name -- this is important to conserve token usage. Use the `Profile` tool to understand the columns and their sizes.",
Copy file name to clipboardExpand all lines: src/fenic/api/mcp/tools.py
+54-33Lines changed: 54 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -14,46 +14,67 @@
14
14
fromdataclassesimportdataclass
15
15
fromtypingimport (
16
16
List,
17
+
Optional,
17
18
)
18
19
19
-
fromfenic.api.mcp._tool_generation_utilsimport (
20
-
auto_generate_system_tools,
21
-
build_datasets_from_tables,
22
-
)
23
-
fromfenic.api.session.sessionimportSession
24
-
fromfenic.core.mcp.typesimportSystemTool
25
-
26
20
27
21
@dataclass
28
-
classToolGenerationConfig:
29
-
"""Configuration for automated tool generation.
22
+
classSystemToolConfig:
23
+
"""Configuration for canonical system tools.
30
24
31
-
Attributes:
32
-
table_names: List of table names.
33
-
tool_group_name: Name of the tool group.
34
-
max_result_rows: Maximum number of rows to be returned from Read/Analyze tools.
35
-
"""
25
+
fenic can automatically generate a set of canonical tools for operating on one or more fenic tables.
36
26
37
-
table_names: List[str]
38
-
tool_group_name: str
39
-
max_result_rows: int=100
27
+
- Schema: list columns/types for any or all tables
28
+
- Profile: column statistics (counts, basic numeric analysis [min, max, mean, etc.], contextual information for text columns [average_length, etc.])
29
+
- Read: read a selection of rows from a single table. These rows can be paged over, filtered and can use column projections.
30
+
- Search Summary: regex search across all text columns in all tables -- returns back dataframe names with result counts.
31
+
- Search Content: regex search across a single table, specifying one or more text columns to search across -- returns back rows corresponding to the query.
32
+
- Analyze: Write raw SQL to perform complex analysis on one or more tables.
40
33
34
+
Attributes:
35
+
table_names: List of the fenic table names the tools should be able to access. If not provided, the generated tools will be able to access all tables in the catalog.
36
+
tool_namespace: If provided, will prefix the names of the generated tools with this namespace value.
37
+
For example, by default the generated tools will be named `read`, `profile`, etc. With multiple fenic
38
+
MCP servers, these tool names will clash, which can be confusing. In order to disambiguate, the `tool_namespace`
39
+
is prefixed to the tool name (in snake case), so a `tool_namespace` of `fenic` would create the tools `fenic_read`,
40
+
`fenic_profile`, etc.
41
+
max_result_rows: Maximum number of rows to be returned from Read/Analyze tools.
41
42
42
-
defauto_generate_system_tools_from_tables(
43
-
table_names: List[str],
44
-
session: Session,
45
-
*,
46
-
tool_group_name: str,
47
-
max_result_limit: int=100,
48
-
) ->List[SystemTool]:
49
-
"""Generate Schema/Profile/Read/Search/Analyze tools from catalog tables.
43
+
Example:
44
+
```python
45
+
from fenic import SystemToolConfig
46
+
from fenic.api.mcp.tools import SystemToolConfig
47
+
from fenic.api.mcp.server import create_mcp_server
0 commit comments