import { RequestContext } from "../requestContext.js";
import { ZodTypeAny, z } from "zod";
import zodToJsonSchema from "zod-to-json-schema";
import { TablesTool } from "./tables.js";
import { DataTool } from "./data.js";
import { StatusTool } from "./status.js";
import { FunctionSpecTool } from "./functionSpec.js";
import { RunTool } from "./run.js";
import { EnvListTool, EnvGetTool, EnvSetTool, EnvRemoveTool } from "./env.js";
import { RunOneoffQueryTool } from "./runOneoffQuery.js";
import { LogsTool } from "./logs.js";
import { InsightsTool } from "./insights.js";
import { Tool } from "@modelcontextprotocol/sdk/types.js";
export type ConvexTool = {
name: string;
description: string;
inputSchema: Input;
outputSchema: Output;
handler: (
ctx: RequestContext,
input: z.infer,
) => Promise>;
};
type ToolInput = Tool["inputSchema"];
export function mcpTool(tool: ConvexTool): Tool {
return {
name: tool.name,
description: tool.description,
inputSchema: zodToJsonSchema(tool.inputSchema) as ToolInput,
};
}
export const convexTools: ConvexTool[] = [
StatusTool,
DataTool,
TablesTool,
FunctionSpecTool,
RunTool,
EnvListTool,
EnvGetTool,
EnvSetTool,
EnvRemoveTool,
RunOneoffQueryTool,
LogsTool,
InsightsTool,
];