recommend_doc_workflow
Plans the next documentation lookups for a given MTA:SA task, guiding AI to call the right tools and avoid manual scraping.
Instructions
Planner tool that tells LLMs exactly which mtasa-docs tools to call next for a given task. Use this to enforce MCP-first workflows and avoid manual wiki scraping.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_description | Yes | What the user wants to build or debug | |
| known_function_names | No | Function names already known in the conversation |
Implementation Reference
- src/index.ts:645-720 (handler)The handler function for the recommend_doc_workflow tool. It takes task_description and known_function_names, uses findRelatedFunctions and other helpers to build a recommended workflow output string with steps for discovery, documentation retrieval, example extraction, and implementation rules.
async ({ task_description, known_function_names, }): Promise<CallToolResult> => { const normalizedKnown = dedupeFunctionsByName( known_function_names .map(normalizeFunctionInput) .map((name) => findMetadataByName(name)) .filter((item): item is MtasaFunction => Boolean(item)), ); const taskMatches = dedupeFunctionsByName( findRelatedFunctions(task_description, 8), ); const eventTaskMatches = filterEventEntries(taskMatches).slice(0, 6); const searchHints = task_description .split(/[^A-Za-z0-9_]+/) .map((word) => word.trim()) .filter((word) => word.length > 2) .slice(0, 6); let output = "# Recommended MCP Workflow\n\n"; output += `Task: ${task_description}\n\n`; output += "1) Discovery\n"; output += "- Call `find_functions_for_task` with the full task description.\n"; output += "- If the task is event-driven, call `find_events_for_task` (or `search_events`) to get event names only.\n"; if (searchHints.length > 0) { output += "- Optional: call `search_functions` with these focused terms: " + searchHints.join(", ") + "\n"; } output += "\n2) Documentation Retrieval\n"; output += "- Call `get_multiple_function_docs` with top candidates before writing code.\n"; output += "- If one function/event is uncertain, call `get_function_docs` individually first.\n"; output += "- By default optional arguments are hidden; set include_optional_arguments=true only when needed.\n"; output += "\n3) Example Extraction\n"; output += "- Call `get_function_examples` for functions where implementation style matters.\n"; output += "\n4) Implementation Rule\n"; output += "- Treat docs returned by this MCP as source of truth for signatures, side (client/server/shared), and deprecations.\n"; if (normalizedKnown.length > 0) { output += "\nKnown valid functions in context:\n"; output += `${formatFunctionList(normalizedKnown)}\n`; } if (taskMatches.length > 0) { output += "\nTop suggested functions for this task:\n"; output += `${formatFunctionList(taskMatches)}\n`; } if (eventTaskMatches.length > 0) { output += "\nTop suggested events for this task:\n"; output += `${formatFunctionList(eventTaskMatches)}\n`; } return { content: [ { type: "text", text: output, }, ], }; }, - src/index.ts:631-644 (schema)Input schema definition for recommend_doc_workflow using Zod. Defines task_description (string, required) and known_function_names (optional array of strings, defaults to empty array).
{ description: "Planner tool that tells LLMs exactly which mtasa-docs tools to call next for a given task. Use this to enforce MCP-first workflows and avoid manual wiki scraping.", inputSchema: { task_description: z .string() .describe("What the user wants to build or debug"), known_function_names: z .array(z.string()) .optional() .default([]) .describe("Function names already known in the conversation"), }, }, - src/index.ts:629-721 (registration)Registration of the recommend_doc_workflow tool via server.registerTool(...) with name, schema, and handler callback.
server.registerTool( "recommend_doc_workflow", { description: "Planner tool that tells LLMs exactly which mtasa-docs tools to call next for a given task. Use this to enforce MCP-first workflows and avoid manual wiki scraping.", inputSchema: { task_description: z .string() .describe("What the user wants to build or debug"), known_function_names: z .array(z.string()) .optional() .default([]) .describe("Function names already known in the conversation"), }, }, async ({ task_description, known_function_names, }): Promise<CallToolResult> => { const normalizedKnown = dedupeFunctionsByName( known_function_names .map(normalizeFunctionInput) .map((name) => findMetadataByName(name)) .filter((item): item is MtasaFunction => Boolean(item)), ); const taskMatches = dedupeFunctionsByName( findRelatedFunctions(task_description, 8), ); const eventTaskMatches = filterEventEntries(taskMatches).slice(0, 6); const searchHints = task_description .split(/[^A-Za-z0-9_]+/) .map((word) => word.trim()) .filter((word) => word.length > 2) .slice(0, 6); let output = "# Recommended MCP Workflow\n\n"; output += `Task: ${task_description}\n\n`; output += "1) Discovery\n"; output += "- Call `find_functions_for_task` with the full task description.\n"; output += "- If the task is event-driven, call `find_events_for_task` (or `search_events`) to get event names only.\n"; if (searchHints.length > 0) { output += "- Optional: call `search_functions` with these focused terms: " + searchHints.join(", ") + "\n"; } output += "\n2) Documentation Retrieval\n"; output += "- Call `get_multiple_function_docs` with top candidates before writing code.\n"; output += "- If one function/event is uncertain, call `get_function_docs` individually first.\n"; output += "- By default optional arguments are hidden; set include_optional_arguments=true only when needed.\n"; output += "\n3) Example Extraction\n"; output += "- Call `get_function_examples` for functions where implementation style matters.\n"; output += "\n4) Implementation Rule\n"; output += "- Treat docs returned by this MCP as source of truth for signatures, side (client/server/shared), and deprecations.\n"; if (normalizedKnown.length > 0) { output += "\nKnown valid functions in context:\n"; output += `${formatFunctionList(normalizedKnown)}\n`; } if (taskMatches.length > 0) { output += "\nTop suggested functions for this task:\n"; output += `${formatFunctionList(taskMatches)}\n`; } if (eventTaskMatches.length > 0) { output += "\nTop suggested events for this task:\n"; output += `${formatFunctionList(eventTaskMatches)}\n`; } return { content: [ { type: "text", text: output, }, ], }; }, );