Skip to content

Commit 03ce63e

Browse files
committed
simplify names further to UserDefinedTool and SystemTool
1 parent e9866b7 commit 03ce63e

File tree

15 files changed

+91
-85
lines changed

15 files changed

+91
-85
lines changed

src/fenic/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@
108108
StructField,
109109
StructType,
110110
StructuredOutputStrategy,
111-
SystemToolDefinition,
111+
SystemTool,
112112
ToolParam,
113113
TranscriptType,
114-
UserDefinedToolDefinition,
114+
UserDefinedTool,
115115
)
116116
from fenic.core.error import InvalidExampleCollectionError
117117
from fenic.core.types.semantic import ModelAlias
@@ -237,8 +237,8 @@
237237
# MCP
238238
"ToolParam",
239239
"BoundToolParam",
240-
"UserDefinedToolDefinition",
241-
"SystemToolDefinition",
240+
"UserDefinedTool",
241+
"SystemTool",
242242
"ToolGenerationConfig",
243243
"create_mcp_server",
244244
"run_mcp_server_asgi",

src/fenic/_backends/cloud/catalog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
TableAlreadyExistsError,
5252
TableNotFoundError,
5353
)
54-
from fenic.core.mcp.types import ToolParam, UserDefinedToolDefinition
54+
from fenic.core.mcp.types import ToolParam, UserDefinedTool
5555
from fenic.core.types import DatasetMetadata, Schema
5656
from fenic.core.types.schema import ColumnField
5757

@@ -341,7 +341,7 @@ def set_view_description(self, view_name: str, description: str) -> bool:
341341
"Set view description not implemented for cloud catalog"
342342
)
343343

344-
def describe_tool(self, tool_name: str) -> UserDefinedToolDefinition:
344+
def describe_tool(self, tool_name: str) -> UserDefinedTool:
345345
"""Find and return the tool from the current database."""
346346
# TODO: Implement get tool for the cloud
347347
raise NotImplementedError(
@@ -368,7 +368,7 @@ def drop_tool(self, tool_name: str, ignore_if_not_exists: bool = True) -> bool:
368368
"Drop tool not implemented for cloud catalog"
369369
)
370370

371-
def list_tools(self) -> List[UserDefinedToolDefinition]:
371+
def list_tools(self) -> List[UserDefinedTool]:
372372
"""Get a list of all tools in the current database."""
373373
raise NotImplementedError(
374374
"List tools not implemented for cloud catalog"

src/fenic/_backends/local/catalog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
ToolNotFoundError,
3131
)
3232
from fenic.core.mcp._tools import bind_tool
33-
from fenic.core.mcp.types import ToolParam, UserDefinedToolDefinition
33+
from fenic.core.mcp.types import ToolParam, UserDefinedTool
3434
from fenic.core.metrics import QueryMetrics
3535
from fenic.core.types import (
3636
DatasetMetadata,
@@ -506,7 +506,7 @@ def set_view_description(self, view_name: str, description: Optional[str]) -> bo
506506
) from e
507507

508508

509-
def describe_tool(self, tool_name: str) -> Optional[UserDefinedToolDefinition]:
509+
def describe_tool(self, tool_name: str) -> Optional[UserDefinedTool]:
510510
"""Get a tool's metadata from the system table."""
511511
cursor = self.db_conn.cursor()
512512
existing_tool = self.system_tables.describe_tool(cursor, tool_name)
@@ -534,7 +534,7 @@ def create_tool(
534534
self.system_tables.save_tool(cursor, tool_definition)
535535
return True
536536

537-
def list_tools(self) -> List[UserDefinedToolDefinition]:
537+
def list_tools(self) -> List[UserDefinedTool]:
538538
"""List all tools in the current catalog."""
539539
cursor = self.db_conn.cursor()
540540
return self.system_tables.list_tools(cursor)

src/fenic/_backends/local/system_table_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from fenic.core._serde.proto.serde_context import SerdeContext
2020
from fenic.core._serde.proto.types import ToolDefinitionProto
2121
from fenic.core.error import CatalogError
22-
from fenic.core.mcp.types import UserDefinedToolDefinition
22+
from fenic.core.mcp.types import UserDefinedTool
2323
from fenic.core.metrics import QueryMetrics
2424
from fenic.core.types import ColumnField, DatasetMetadata, Schema
2525
from fenic.core.types.datatypes import (
@@ -465,7 +465,7 @@ def delete_database_views(self, cursor: duckdb.DuckDBPyConnection, database_name
465465
f"Failed to delete views metadata for database {database_name}"
466466
) from e
467467

468-
def save_tool(self, cursor: duckdb.DuckDBPyConnection, tool: UserDefinedToolDefinition) -> None:
468+
def save_tool(self, cursor: duckdb.DuckDBPyConnection, tool: UserDefinedTool) -> None:
469469
"""Save a tool's metadata to the system table.
470470
Raises:
471471
CatalogError: If the tool metadata cannot be saved.
@@ -486,7 +486,7 @@ def save_tool(self, cursor: duckdb.DuckDBPyConnection, tool: UserDefinedToolDefi
486486
f"Failed to save tool metadata for {tool.name}"
487487
) from e
488488

489-
def describe_tool(self, cursor: duckdb.DuckDBPyConnection, tool_name: str) -> Optional[UserDefinedToolDefinition]:
489+
def describe_tool(self, cursor: duckdb.DuckDBPyConnection, tool_name: str) -> Optional[UserDefinedTool]:
490490
"""Get a tool's metadata from the system table.
491491
Raises:
492492
CatalogError: If the tool metadata cannot be retrieved.
@@ -508,7 +508,7 @@ def describe_tool(self, cursor: duckdb.DuckDBPyConnection, tool_name: str) -> Op
508508
f"Failed to retrieve tool metadata for {tool_name}"
509509
) from e
510510

511-
def list_tools(self, cursor: duckdb.DuckDBPyConnection) -> List[UserDefinedToolDefinition]:
511+
def list_tools(self, cursor: duckdb.DuckDBPyConnection) -> List[UserDefinedTool]:
512512
"""List all tools in the system table.
513513
Raises:
514514
CatalogError: If the tools metadata cannot be retrieved.
@@ -815,7 +815,7 @@ def _initialize_tools_metadata(self, cursor: duckdb.DuckDBPyConnection) -> None:
815815
f"Failed to initialize tools and {TOOLS_METADATA_TABLE} table"
816816
) from e
817817

818-
def _deserialize_and_resolve_tool(self, row: tuple) -> UserDefinedToolDefinition:
818+
def _deserialize_and_resolve_tool(self, row: tuple) -> UserDefinedTool:
819819
decoded_tool = base64.b64decode(row[0])
820820
proto_tool = ToolDefinitionProto.FromString(decoded_tool)
821821
return self.serde_context.deserialize_tool_definition(proto_tool)

src/fenic/api/catalog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from fenic.api.dataframe.dataframe import DataFrame
88
from fenic.core._interfaces.catalog import BaseCatalog
9-
from fenic.core.mcp.types import ToolParam, UserDefinedToolDefinition
9+
from fenic.core.mcp.types import ToolParam, UserDefinedTool
1010
from fenic.core.types import DatasetMetadata, Schema
1111

1212

@@ -654,7 +654,7 @@ def drop_view(self, view_name: str, ignore_if_not_exists: bool = True) -> bool:
654654
return self.catalog.drop_view(view_name, ignore_if_not_exists)
655655

656656
@validate_call(config=ConfigDict(strict=True))
657-
def describe_tool(self, tool_name: str) -> UserDefinedToolDefinition:
657+
def describe_tool(self, tool_name: str) -> UserDefinedTool:
658658
"""Returns the tool with the specified name from the current catalog.
659659
660660
Args:
@@ -747,7 +747,7 @@ def drop_tool(self, tool_name: str, ignore_if_not_exists: bool = True) -> bool:
747747
"""
748748
return self.catalog.drop_tool(tool_name, ignore_if_not_exists)
749749

750-
def list_tools(self) -> List[UserDefinedToolDefinition]:
750+
def list_tools(self) -> List[UserDefinedTool]:
751751
"""Lists the tools available in the current catalog."""
752752
return self.catalog.list_tools()
753753

src/fenic/api/mcp/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
from fenic.api.session.session import Session
1414
from fenic.core.error import ConfigurationError
1515
from fenic.core.mcp._server import FenicMCPServer, MCPTransport
16-
from fenic.core.mcp.types import SystemToolDefinition, UserDefinedToolDefinition
16+
from fenic.core.mcp.types import SystemTool, UserDefinedTool
1717

1818

1919
def create_mcp_server(
2020
session: Session,
2121
server_name: str,
2222
*,
23-
user_defined_tools: Optional[List[UserDefinedToolDefinition]] = None,
23+
user_defined_tools: Optional[List[UserDefinedTool]] = None,
2424
automated_tool_generation: Optional[ToolGenerationConfig] = None,
2525
concurrency_limit: int = 8,
2626
) -> FenicMCPServer:
@@ -33,7 +33,7 @@ def create_mcp_server(
3333
automated_tool_generation: Generate automated tools for one or more Dataframes.
3434
concurrency_limit: Maximum number of concurrent tool executions.
3535
"""
36-
system_tools: List[SystemToolDefinition] = []
36+
system_tools: List[SystemTool] = []
3737
if user_defined_tools is None:
3838
user_defined_tools = []
3939
if automated_tool_generation:

src/fenic/api/mcp/tool_generation.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from fenic.core._logical_plan.plans.base import LogicalPlan
4646
from fenic.core._utils.schema import convert_custom_dtype_to_polars
4747
from fenic.core.error import ConfigurationError, ValidationError
48-
from fenic.core.mcp.types import SystemToolDefinition, TableFormat
48+
from fenic.core.mcp.types import SystemTool, TableFormat
4949
from fenic.core.types.datatypes import (
5050
BooleanType,
5151
DoubleType,
@@ -92,7 +92,7 @@ def auto_generate_system_tools_from_tables(
9292
*,
9393
tool_group_name: str,
9494
max_result_limit: int = 100,
95-
) -> List[SystemToolDefinition]:
95+
) -> List[SystemTool]:
9696
"""Generate Schema/Profile/Read/Search/Analyze tools from catalog tables.
9797
9898
Validates that each table exists and has a non-empty description in catalog metadata.
@@ -112,7 +112,7 @@ def _auto_generate_read_tool(
112112
tool_description: str,
113113
*,
114114
result_limit: int = 50,
115-
) -> SystemToolDefinition:
115+
) -> SystemTool:
116116
"""Create a read tool over one or many datasets."""
117117
if len(datasets) == 0:
118118
raise ConfigurationError("Cannot create read tool: no datasets provided.")
@@ -165,7 +165,7 @@ async def read_func(
165165
sort_ascending=sort_ascending,
166166
)
167167

168-
return SystemToolDefinition(
168+
return SystemTool(
169169
name=tool_name,
170170
description=tool_description,
171171
func=read_func,
@@ -179,7 +179,7 @@ def _auto_generate_search_summary_tool(
179179
session: Session,
180180
tool_name: str,
181181
tool_description: str,
182-
) -> SystemToolDefinition:
182+
) -> SystemTool:
183183
"""Create a grep-like summary tool over one or many datasets (string columns)."""
184184
if len(datasets) == 0:
185185
raise ValueError("Cannot create search summary tool: no datasets provided.")
@@ -205,7 +205,7 @@ async def search_summary(
205205
pl_df = pl.DataFrame(rows)
206206
return InMemorySource.from_session_state(pl_df, session._session_state)
207207

208-
return SystemToolDefinition(
208+
return SystemTool(
209209
name=tool_name,
210210
description=tool_description,
211211
func=search_summary,
@@ -220,7 +220,7 @@ def _auto_generate_search_content_tool(
220220
tool_description: str,
221221
*,
222222
result_limit: int = 100,
223-
) -> SystemToolDefinition:
223+
) -> SystemTool:
224224
"""Create a content search tool for a single dataset (string columns)."""
225225
if len(datasets) == 0:
226226
raise ValidationError("Cannot create search content tool: no datasets provided.")
@@ -276,7 +276,7 @@ async def search_rows(
276276
sort_ascending=sort_ascending,
277277
)
278278

279-
return SystemToolDefinition(
279+
return SystemTool(
280280
name=tool_name,
281281
description=tool_description,
282282
func=search_rows,
@@ -290,7 +290,7 @@ def _auto_generate_schema_tool(
290290
session: Session,
291291
tool_name: str,
292292
tool_description: str,
293-
) -> SystemToolDefinition:
293+
) -> SystemTool:
294294
"""Create a schema tool over one or many datasets.
295295
296296
- Returns one row per dataset with a column `schema` containing a list of
@@ -337,7 +337,7 @@ async def schema_func(
337337
session._session_state,
338338
)
339339

340-
return SystemToolDefinition(
340+
return SystemTool(
341341
name=tool_name,
342342
description=tool_description.strip(),
343343
func=schema_func,
@@ -352,7 +352,7 @@ def _auto_generate_sql_tool(
352352
tool_description: str,
353353
*,
354354
result_limit: int = 100,
355-
) -> SystemToolDefinition:
355+
) -> SystemTool:
356356
"""Create an Analyze tool that executes DuckDB SELECT SQL across datasets.
357357
358358
- JOINs between the provided datasets are allowed.
@@ -389,7 +389,7 @@ async def analyze_func(
389389
)
390390
enhanced_description = "\n".join(lines)
391391

392-
tool = SystemToolDefinition(
392+
tool = SystemTool(
393393
name=tool_name,
394394
description=enhanced_description,
395395
func=analyze_func,
@@ -485,7 +485,7 @@ def _auto_generate_profile_tool(
485485
tool_description: str,
486486
*,
487487
topk_distinct: int = 10,
488-
) -> SystemToolDefinition:
488+
) -> SystemTool:
489489
"""Create a cached Profile tool for one or many datasets.
490490
491491
Output columns include:
@@ -525,7 +525,7 @@ async def profile_func(
525525

526526
return profile_df._logical_plan
527527

528-
return SystemToolDefinition(
528+
return SystemTool(
529529
name=tool_name,
530530
description=tool_description,
531531
func=profile_func,
@@ -700,7 +700,7 @@ def _auto_generate_system_tools(
700700
*,
701701
tool_group_name: str,
702702
max_result_limit: int = 100,
703-
) -> List[SystemToolDefinition]:
703+
) -> List[SystemTool]:
704704
"""Generate core tools spanning all datasets: Schema, Profile, Analyze.
705705
706706
- Schema: list columns/types for any or all datasets

src/fenic/core/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from fenic.core.mcp import (
44
BoundToolParam,
5-
SystemToolDefinition,
5+
SystemTool,
66
ToolParam,
7-
UserDefinedToolDefinition,
7+
UserDefinedTool,
88
)
99
from fenic.core.metrics import (
1010
LMMetrics,
@@ -105,6 +105,6 @@
105105
# MCP
106106
"ToolParam",
107107
"BoundToolParam",
108-
"UserDefinedToolDefinition",
109-
"SystemToolDefinition",
108+
"UserDefinedTool",
109+
"SystemTool",
110110
]

src/fenic/core/_interfaces/catalog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
if TYPE_CHECKING:
99
from fenic.core._logical_plan.plans.base import LogicalPlan
10-
from fenic.core.mcp.types import ToolParam, UserDefinedToolDefinition
10+
from fenic.core.mcp.types import ToolParam, UserDefinedTool
1111

1212

1313
class BaseCatalog(ABC):
@@ -145,7 +145,7 @@ def describe_view(self, view_name: str) -> DatasetMetadata:
145145
pass
146146

147147
@abstractmethod
148-
def describe_tool(self, tool_name: str) -> UserDefinedToolDefinition:
148+
def describe_tool(self, tool_name: str) -> UserDefinedTool:
149149
"""Find and return the tool from the current catalog."""
150150
pass
151151

@@ -168,6 +168,6 @@ def drop_tool(self, tool_name: str, ignore_if_not_exists: bool = True) -> bool:
168168
pass
169169

170170
@abstractmethod
171-
def list_tools(self) -> List[UserDefinedToolDefinition]:
171+
def list_tools(self) -> List[UserDefinedTool]:
172172
"""Get a list of all tools in the current catalog."""
173173
pass

src/fenic/core/_serde/proto/serde_context.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
from fenic.core._utils.structured_outputs import (
5454
check_if_model_uses_unserializable_features,
5555
)
56-
from fenic.core.mcp.types import BoundToolParam, UserDefinedToolDefinition
56+
from fenic.core.mcp.types import BoundToolParam, UserDefinedTool
5757
from fenic.core.types.datatypes import DataType
5858
from fenic.core.types.schema import ColumnField, Schema
5959

@@ -918,7 +918,7 @@ def deserialize_tool_parameter(
918918

919919
def serialize_tool_definition(
920920
self,
921-
tool_definition: UserDefinedToolDefinition,
921+
tool_definition: UserDefinedTool,
922922
field_name: str = "tool_definition"
923923
) -> ToolDefinitionProto:
924924
with self.path_context(field_name):
@@ -941,11 +941,11 @@ def deserialize_tool_definition(
941941
self,
942942
tool_definition_proto: ToolDefinitionProto,
943943
field_name: str = "tool_definition"
944-
) -> UserDefinedToolDefinition:
944+
) -> UserDefinedTool:
945945
"""Deserialize a ToolDefinition."""
946946
with self.path_context(field_name):
947947
try:
948-
return UserDefinedToolDefinition(
948+
return UserDefinedTool(
949949
name=tool_definition_proto.name,
950950
description=tool_definition_proto.description,
951951
params=[self.deserialize_tool_parameter(tool_param) for tool_param in tool_definition_proto.params],

0 commit comments

Comments
 (0)