get_api_reference
Retrieve comprehensive API documentation for Ember.js classes, modules, or methods to understand parameters, return values, and usage examples.
Instructions
Get detailed API reference documentation for a specific Ember class, module, or method. Returns full API documentation including parameters, return values, examples, and links to official API docs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the API element (e.g., 'Component', '@glimmer/component', 'Service', 'Router') | |
| type | No | Type of API element (optional) |
Implementation Reference
- index.js:195-219 (handler)MCP tool handler for 'get_api_reference' that extracts arguments, retrieves API documentation from service, handles not found case, formats the response, and returns as MCP content.async handleGetApiReference(args) { const { name, type } = args; const apiDoc = await this.docService.getApiReference(name, type); if (!apiDoc) { return { content: [ { type: "text", text: `No API documentation found for "${name}". Try searching with search_ember_docs first.`, }, ], }; } const formattedDoc = formatApiReference(apiDoc, this.docService.deprecationManager); return { content: [ { type: "text", text: formattedDoc, }, ], }; }
- index.js:77-97 (registration)Registration of the 'get_api_reference' tool in the listTools handler, including name, description, and input schema.{ name: "get_api_reference", description: "Get detailed API reference documentation for a specific Ember class, module, or method. Returns full API documentation including parameters, return values, examples, and links to official API docs.", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the API element (e.g., 'Component', '@glimmer/component', 'Service', 'Router')", }, type: { type: "string", enum: ["class", "module", "method", "property"], description: "Type of API element (optional)", }, }, required: ["name"], }, },
- lib/documentation-service.js:510-559 (handler)Core implementation of API reference retrieval: looks up in indexed API docs, falls back to search and JSON parsing from documentation content, adds deprecation info and API URL.async getApiReference(name, type) { const key = name.toLowerCase(); const apiDoc = this.apiIndex.get(key); if (!apiDoc) { // Try to search for it const results = await this.search(name, "api", 1); if (results.length > 0 && results[0].apiLink) { // Try to extract from the content const apiDocs = this.sections["api-docs"] || []; for (const doc of apiDocs) { if (doc.content.toLowerCase().includes(key)) { try { const jsonMatch = doc.content.match(/\{[\s\S]*"data"[\s\S]*\}/); if (jsonMatch) { const parsed = JSON.parse(jsonMatch[0]); if (parsed.data?.attributes) { const attrs = parsed.data.attributes; return { name: attrs.name || attrs.shortname, type: parsed.data.type, module: attrs.module, description: attrs.description, file: attrs.file, line: attrs.line, extends: attrs.extends, methods: attrs.methods || [], properties: attrs.properties || [], apiUrl: results[0].apiLink, }; } } } catch (e) { // Continue searching } } } } return null; } // Check if API is deprecated const deprecationInfo = this.deprecationManager.getDeprecationInfo(apiDoc.name); return { ...apiDoc, apiUrl: generateApiUrl(apiDoc.name, apiDoc.type), deprecationInfo: deprecationInfo, }; }
- index.js:81-97 (schema)Input schema for the 'get_api_reference' tool defining parameters 'name' (required string) and 'type' (optional enum).inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the API element (e.g., 'Component', '@glimmer/component', 'Service', 'Router')", }, type: { type: "string", enum: ["class", "module", "method", "property"], description: "Type of API element (optional)", }, }, required: ["name"], }, },
- lib/formatters.js:65-142 (helper)Helper function to format the raw API documentation object into a comprehensive markdown response including deprecation warnings, description, methods, properties, and links.export function formatApiReference(apiDoc, deprecationManager) { let output = `# ${apiDoc.name}\n\n`; // Add deprecation warning if applicable if (apiDoc.deprecationInfo) { output += deprecationManager.generateWarning(apiDoc.name, 'banner'); } if (apiDoc.module) { output += `**Module:** \`${apiDoc.module}\`\n\n`; } if (apiDoc.type) { output += `**Type:** ${apiDoc.type}\n\n`; } if (apiDoc.description) { output += `## Description\n\n${apiDoc.description}\n\n`; } if (apiDoc.extends) { output += `**Extends:** ${apiDoc.extends}\n\n`; } if (apiDoc.file) { output += `**Source:** \`${apiDoc.file}\``; if (apiDoc.line) { output += `:${apiDoc.line}`; } output += `\n\n`; } if (apiDoc.methods && apiDoc.methods.length > 0) { output += `## Methods\n\n`; apiDoc.methods.slice(0, 10).forEach((method) => { output += `### ${method.name}\n\n`; if (method.description) { output += `${method.description}\n\n`; } if (method.params && method.params.length > 0) { output += `**Parameters:**\n`; method.params.forEach((param) => { output += `- \`${param.name}\``; if (param.type) output += ` (${param.type})`; if (param.description) output += `: ${param.description}`; output += `\n`; }); output += `\n`; } if (method.return) { output += `**Returns:** ${method.return.type || "void"}`; if (method.return.description) { output += ` - ${method.return.description}`; } output += `\n\n`; } }); } if (apiDoc.properties && apiDoc.properties.length > 0) { output += `## Properties\n\n`; apiDoc.properties.slice(0, 10).forEach((prop) => { output += `### ${prop.name}\n\n`; if (prop.description) { output += `${prop.description}\n\n`; } if (prop.type) { output += `**Type:** ${prop.type}\n\n`; } }); } if (apiDoc.apiUrl) { output += `\n**Full API Documentation:** ${apiDoc.apiUrl}\n`; } return output; }