Skip to main content
Glama
rp4

IIA-MCP Server

by rp4

search_documents

Query IIA documents by keywords, standard numbers, or topics to retrieve relevant standards, guidance, glossary terms, or resources for audit compliance and accurate guidance.

Instructions

Search IIA documents by keywords, standard numbers, or topics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoFilter by category (standards, guidance, topics, glossary)
limitNoMaximum number of results to return
queryYesSearch query (keywords, standard number, or topic)

Implementation Reference

  • Core handler function that executes the search_documents tool. Searches the indexed documents based on query, filters by optional category, limits results, calculates relevance, extracts excerpts, formats output for MCP response.
    private async searchDocuments(query: string, category?: string, limit: number = 10): Promise<any> {
      const results: SearchResult[] = [];
      
      for (const [filePath, metadata] of this.documentIndex.entries()) {
        if (category && metadata.category !== category) {
          continue;
        }
    
        const relevance = this.calculateRelevance(query, metadata, filePath);
        if (relevance > 0) {
          const content = await this.getDocumentContent(filePath);
          const excerpt = this.extractExcerpt(content, query);
          
          results.push({
            file: filePath,
            title: metadata.title,
            category: metadata.category,
            relevance,
            excerpt,
          });
        }
      }
    
      results.sort((a, b) => b.relevance - a.relevance);
      const topResults = results.slice(0, limit);
    
      const formattedResults = topResults.map(result => 
        `**${result.title}** (${result.category})\n${result.excerpt}\n*File: ${result.file}*`
      ).join('\n\n---\n\n');
    
      return {
        content: [
          {
            type: 'text',
            text: `Found ${results.length} documents matching "${query}":\n\n${formattedResults}`,
          },
        ],
      };
    }
  • Tool registration in the ListTools handler, defining name, description, and input schema.
    {
      name: 'search_documents',
      description: 'Search IIA documents by keywords, standard numbers, or topics',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query (keywords, standard number, or topic)',
          },
          category: {
            type: 'string',
            description: 'Filter by category (standards, guidance, topics, glossary)',
            enum: ['standards', 'guidance', 'topics', 'glossary'],
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results to return',
            default: 10,
          },
        },
        required: ['query'],
      },
    },
    {
  • Type definition for search results used in the handler.
    interface SearchResult {
      file: string;
      title: string;
      category: string;
      relevance: number;
      excerpt: string;
    }
  • Helper function to calculate relevance score for documents matching the search query.
    private calculateRelevance(query: string, metadata: DocumentMetadata, filePath: string): number {
      const lowerQuery = query.toLowerCase();
      let score = 0;
    
      // Exact standard number match
      if (metadata.standardNumber === query) {
        score += 100;
      }
    
      // Title matches
      if (metadata.title.toLowerCase().includes(lowerQuery)) {
        score += 50;
      }
    
      // Tag matches
      if (metadata.tags.some(tag => tag.toLowerCase().includes(lowerQuery))) {
        score += 30;
      }
    
      // Filename matches
      if (filePath.toLowerCase().includes(lowerQuery)) {
        score += 20;
      }
    
      // Partial standard number match
      if (metadata.standardNumber && metadata.standardNumber.includes(query)) {
        score += 40;
      }
    
      return score;
    }
  • Helper function to extract relevant excerpt from document content around the query match.
    private extractExcerpt(content: string, query: string): string {
      const lines = content.split('\n');
      const lowerQuery = query.toLowerCase();
      
      for (let i = 0; i < lines.length; i++) {
        if (lines[i].toLowerCase().includes(lowerQuery)) {
          const start = Math.max(0, i - 1);
          const end = Math.min(lines.length, i + 3);
          return lines.slice(start, end).join('\n').substring(0, 200) + '...';
        }
      }
      
      return lines.slice(0, 3).join('\n').substring(0, 200) + '...';
    }
  • Dispatch case in CallToolRequestSchema handler that routes to the searchDocuments method.
    case 'search_documents':
      return this.searchDocuments(args.query, args.category, args.limit);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It mentions what can be searched (keywords, standard numbers, topics) but doesn't describe how results are returned, whether there's pagination, authentication requirements, rate limits, or what happens with no matches. For a search tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without any unnecessary words. It's appropriately sized and front-loaded with the core purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (search functionality with 3 parameters) and lack of both annotations and output schema, the description is incomplete. It doesn't explain return values, result format, error conditions, or behavioral constraints, leaving significant gaps for an AI agent to understand how to properly use this tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents all three parameters (query, category, limit). The description adds marginal value by listing searchable content types (keywords, standard numbers, topics) which aligns with the query parameter, but doesn't provide additional syntax or format details beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as searching IIA documents with specific search criteria (keywords, standard numbers, or topics). It uses a specific verb ('search') and identifies the resource ('IIA documents'), but doesn't distinguish it from sibling tools like 'get_related_documents' or 'get_standard_details' which might also retrieve document information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose search_documents over sibling tools like get_related_documents or get_standard_details, nor does it specify any prerequisites or exclusions for its use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/rp4/IIA-MCP'

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