28 lines
796 B
Python
28 lines
796 B
Python
"""Utility tools for MCP."""
|
|
|
|
import json
|
|
|
|
from core.mcp.auth import MCPContext, execute_graphql
|
|
from core.mcp.base import mcp, json_response, error_response
|
|
|
|
|
|
@mcp.tool()
|
|
async def graphql_query(query: str, variables: str = None) -> str:
|
|
"""
|
|
Execute a raw GraphQL query. Uses the active profile for authentication context.
|
|
|
|
Args:
|
|
query: The GraphQL query string
|
|
variables: Optional JSON string of variables
|
|
|
|
Returns:
|
|
JSON string containing the query result
|
|
"""
|
|
profile = MCPContext.get_profile()
|
|
if not profile:
|
|
return error_response("No active profile. Call set_active_profile first.")
|
|
|
|
vars_dict = json.loads(variables) if variables else None
|
|
result = await execute_graphql(query, vars_dict)
|
|
return json_response(result)
|