Skip to main content
Glama

search_docs

Search Solana documentation for specific queries using the solana-docs-mcp-server. Quickly find relevant information with a structured search tool.

Instructions

Search through Solana documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query

Implementation Reference

  • The primary handler function implementing the logic for the 'search_docs' tool. It validates input, crawls Solana docs navigation, searches page contents using cheerio, collects matching sections, and returns JSON-formatted results.
    private async handleSearchDocs(args: any) { if (!args.query || typeof args.query !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid query parameter'); } try { // First get the main page to extract sections const mainResponse = await axios.get(this.baseDocsUrl); const $ = cheerio.load(mainResponse.data); const searchResults: DocSection[] = []; // Search through main navigation items const navItems = $('.sidebar-nav').find('a'); const searchPromises = navItems.map(async (_, el) => { const href = $(el).attr('href'); if (href && !href.startsWith('http')) { try { const pageResponse = await axios.get(`${this.baseDocsUrl}${href}`); const page$ = cheerio.load(pageResponse.data); const content = page$('.markdown-section').text(); if (content.toLowerCase().includes(args.query.toLowerCase())) { searchResults.push({ title: page$('h1').first().text() || $(el).text(), content: content.substring(0, 200) + '...', // Preview url: `${this.baseDocsUrl}${href}`, }); } } catch (error) { console.error(`Error searching page ${href}:`, error); } } }).get(); await Promise.all(searchPromises); return { content: [ { type: 'text', text: JSON.stringify({ query: args.query, results: searchResults, timestamp: new Date().toISOString(), }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error searching docs: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
  • Tool schema definition in server capabilities, including name, description, and input schema requiring a 'query' string.
    search_docs: { name: 'search_docs', description: 'Search through Solana documentation', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query', }, }, required: ['query'], }, },
  • src/index.ts:107-120 (registration)
    Registration of 'search_docs' tool in the ListTools response handler, providing schema for tool discovery.
    { name: 'search_docs', description: 'Search through Solana documentation', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query', }, }, required: ['query'], }, },
  • src/index.ts:142-143 (registration)
    Dispatch case in CallToolRequest handler routing 'search_docs' calls to the handleSearchDocs method.
    case 'search_docs': return await this.handleSearchDocs(request.params.arguments);

Other Tools

Related Tools

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/aldrin-labs/solana-docs-mcp-server'

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