list_functions_by_category
List all canonical functions and events in a selected category. Helps discover specific API elements when search terms are unclear.
Instructions
Enumerate canonical function/event names in a category. Useful for discovery when query terms are vague.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | The category to list functions from | |
| limit | No | Maximum number of results to return |
Implementation Reference
- src/index.ts:557-595 (registration)Registration of the 'list_functions_by_category' tool with MCP server, including inputSchema (category enum, limit) and the handler callback.
// Register tool: list_functions_by_category server.registerTool( "list_functions_by_category", { description: "Enumerate canonical function/event names in a category. Useful for discovery when query terms are vague.", inputSchema: { category: z .enum(FUNCTION_CATEGORIES) .describe("The category to list functions from"), limit: z .number() .int() .min(1) .max(500) .optional() .default(100) .describe("Maximum number of results to return"), }, }, async ({ category, limit }): Promise<CallToolResult> => { const results = listFunctionsByCategory(category, limit); const formatted = results.map( (f: MtasaFunction) => `${f.name} [${f.side}]`, ); const body = formatted.length > 0 ? formatted.join("\n") : "No functions found."; return { content: [ { type: "text", text: `MTA:SA functions in category "${category}" (showing ${results.length}):\n\n${body}`, }, ], }; }, ); - src/index.ts:577-595 (handler)Handler callback for the tool: calls listFunctionsByCategory from queries, formats results as text, and returns CallToolResult.
async ({ category, limit }): Promise<CallToolResult> => { const results = listFunctionsByCategory(category, limit); const formatted = results.map( (f: MtasaFunction) => `${f.name} [${f.side}]`, ); const body = formatted.length > 0 ? formatted.join("\n") : "No functions found."; return { content: [ { type: "text", text: `MTA:SA functions in category "${category}" (showing ${results.length}):\n\n${body}`, }, ], }; }, ); - src/index.ts:563-575 (schema)InputSchema for the tool: 'category' (enum of FUNCTION_CATEGORIES) and optional 'limit' (1-500, default 100).
inputSchema: { category: z .enum(FUNCTION_CATEGORIES) .describe("The category to list functions from"), limit: z .number() .int() .min(1) .max(500) .optional() .default(100) .describe("Maximum number of results to return"), }, - src/database/queries.ts:160-167 (helper)Helper function listFunctionsByCategory that queries the database by category with a clamped limit, returns MtasaFunction[].
export const listFunctionsByCategory = ( category: string, limit: number = 100, ): MtasaFunction[] => { const safeLimit = clampLimit(limit, 100, 500); const rows = queries.getByCategory().all(category, safeLimit); return rows as MtasaFunction[]; }; - src/database/queries.ts:70-73 (helper)SQL prepared statement getByCategory: SELECT * FROM function_metadata WHERE category = ? ORDER BY name COLLATE NOCASE LIMIT ?.
getByCategory: () => db.prepare(` SELECT * FROM function_metadata WHERE category = ? ORDER BY name COLLATE NOCASE LIMIT ? `),