podbc_sparql_func
Query and process SPARQL-based data directly through SQLAlchemy connectivity, enabling integration with any DBMS accessible via SQLAlchemy.
Instructions
Call ???.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | ||
| prompt | Yes | ||
| url | No |
Implementation Reference
- mcp_sqlalchemy_server/server.py:480-504 (handler)The main handler function `podbc_sparql_func` that connects to the database using pyodbc, executes the SQL command `select DEMO.DBA.OAI_SPARQL_FUNC(?, ?) as result` with the prompt and API key, and returns the result.def podbc_sparql_func(prompt: str, api_key:Optional[str]=None, user:Optional[str]=None, password:Optional[str]=None, dsn:Optional[str]=None) -> str: """ Call SPARQL AI func. Args: prompt (str): The prompt. api_key (str): optional. user (Optional[str]=None): Optional username. password (Optional[str]=None): Optional password. dsn (Optional[str]=None): Optional dsn name. Returns: str: Results data in JSON. """ try: _api_key = api_key if api_key is not None else API_KEY with get_connection(True, user, password, dsn) as conn: cursor = conn.cursor() cmd = f"select DEMO.DBA.OAI_SPARQL_FUNC(?, ?) as result" rs = cursor.execute(cmd, (prompt, _api_key,)).fetchone() return rs[0] except pyodbc.Error as e: logging.error(f"Error executing request") raise pyodbc.Error("Error executing request")
- mcp_sqlalchemy_server/server.py:476-479 (registration)The `@mcp.tool` decorator registers the `podbc_sparql_func` tool, specifying its name and description.@mcp.tool( name="podbc_sparql_func", description="Tool to use the SPARQL AI support function" )
- mcp_sqlalchemy_server/__init__.py:36-36 (registration)The tool function is included in the package's `__all__` list for easy import."podbc_sparql_func",
- The `podbc_sparql_func` function is imported from server.py in the package init for re-export.podbc_sparql_func,