Skip to main content
Glama

search_mdn

Find web development documentation on MDN Web Docs by entering search queries to access technical references and guides.

Instructions

Search MDN Web Docs for web development documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query

Implementation Reference

  • Core handler function for search_mdn tool. Queries MDN search API with the given query, caches results using NodeCache for 1 hour, formats and returns top 5 results as a string.
    private async searchMDN(query: string): Promise<string> { const cacheKey = `mdn:${query}`; const cached = cache.get<string>(cacheKey); if (cached) return cached; try { const response = await this.axiosInstance.get( 'https://developer.mozilla.org/api/v1/search', { params: { q: query, locale: 'en-US' } } ); const results = response.data.documents.slice(0, 5).map((doc: any, i: number) => `${i + 1}. ${doc.title}\n ${doc.summary}\n https://developer.mozilla.org${doc.mdn_url}\n` ).join('\n'); cache.set(cacheKey, results); return results; } catch (error) { throw new McpError( ErrorCode.InternalError, `MDN API error: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
  • src/index.ts:340-353 (registration)
    Tool registration in listTools handler, including name 'search_mdn', description, and input schema requiring a 'query' string.
    { name: 'search_mdn', description: 'Search MDN Web Docs for web development documentation', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query' } }, required: ['query'] } },
  • Dispatch handler in CallToolRequestSchema that extracts the query argument and invokes the searchMDN function, returning the result as MCP text content.
    case 'search_mdn': { const { query } = request.params.arguments as { query: string }; const results = await this.searchMDN(query); return { content: [ { type: 'text', text: results } ] };
  • Input schema definition for search_mdn tool, specifying an object with required 'query' string property.
    inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query' } }, required: ['query'] }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nahmanmate/code-research-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server