Skip to main content
Glama

search_function

Find DayZ vanilla scripting functions using natural language queries. Describe what you need, like 'copy weapon attachments', and get matching functions.

Instructions

Search for functions in DayZ vanilla scripts by semantic description

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesNatural language description of what you need, e.g., "copy weapon attachments"
searchTypeNoSearch type: semantic (default) for meaning, exact for pattern matching
limitNoMaximum results (1-20, default 5)

Implementation Reference

  • Zod validation schema for search_function tool: accepts query (string), searchType (enum: semantic/exact/fuzzy, default semantic), limit (number 1-20, default 5)
    const SearchFunctionSchema = z.object({
      query: z.string().describe('Search query describing what function you need'),
      searchType: z.enum(['semantic', 'exact', 'fuzzy']).default('semantic'),
      limit: z.number().min(1).max(20).default(5)
    });
  • Tool registration in the MCP ListTools handler: defines 'search_function' with description and JSON Schema input schema
    tools: [
      {
        name: 'search_function',
        description: 'Search for functions in DayZ vanilla scripts by semantic description',
        inputSchema: {
          type: 'object',
          properties: {
            query: {
              type: 'string',
              description: 'Natural language description of what you need, e.g., "copy weapon attachments"'
            },
            searchType: {
              type: 'string',
              enum: ['semantic', 'exact', 'fuzzy'],
              description: 'Search type: semantic (default) for meaning, exact for pattern matching'
            },
            limit: {
              type: 'number',
              description: 'Maximum results (1-20, default 5)'
            }
          },
          required: ['query']
        }
      },
  • Tool handler logic for 'search_function' case in CallToolRequestSchema switch: parses args via SearchFunctionSchema, dispatches to index.semanticSearch or index.exactSearch based on searchType, returns formatted JSON results with type, name, class, text (truncated 300 chars), and similarity
    switch (request.params.name) {
      case 'search_function': {
        const args = SearchFunctionSchema.parse(request.params.arguments);
        
        let results;
        if (args.searchType === 'semantic') {
          results = await this.index.semanticSearch(args.query, args.limit);
        } else {
          results = await this.index.exactSearch(args.query);
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                query: args.query,
                results: results.map(r => ({
                  type: r.type,
                  name: r.methodName || r.className || r.enumName,
                  class: r.className,
                  text: r.text.substring(0, 300),
                  similarity: r.similarity
                }))
              }, null, 2)
            }
          ]
        };
      }
  • semanticSearch() implementation on FileSystemIndex: tokenizes query, creates embedding, computes BM25/semantic/lexical/symbol/field scores with type weighting, intent boosts, and noise penalties, returns top results by similarity
    async semanticSearch(query: string, limit: number = 10): Promise<EmbeddingEntry[]> {
      if (!this.initialized) await this.initialize();
    
      const queryTokens = this.tokenizeForSearch(query);
      const expandedQueryTokens = this.expandQueryTokens(queryTokens);
      const queryUniqueTerms = Array.from(new Set(expandedQueryTokens));
      const queryVector = this.createEmbedding(query);
      const queryLower = query.toLowerCase();
      const hasActionIntent = this.hasActionIntent(queryUniqueTerms);
      const hasRpcIntent = queryUniqueTerms.includes('rpc');
      const hasClientIntent = queryUniqueTerms.includes('client');
      const hasServerIntent = queryUniqueTerms.includes('server');
    
      const queryTermSet = new Set(queryUniqueTerms);
      const intermediate = this.embeddings.map(entry => {
        const bm25Score = this.computeBm25Score(queryUniqueTerms, entry.id);
        const semanticScore = this.cosineSimilarity(queryVector, entry.embedding);
        const lexicalScore = this.computeLexicalScore(queryTermSet, entry.text);
        const symbolScore = this.computeSymbolScore(queryLower, entry);
        const fieldScore = this.computeFieldScore(queryUniqueTerms, entry.id);
        const typeWeight = this.computeTypeWeight(entry, hasActionIntent);
        const intentBoost = this.computeIntentBoost(entry, hasRpcIntent, hasClientIntent, hasServerIntent);
        const noisePenalty = this.computeNoisePenalty(entry);
    
        return {
          entry,
          bm25Score,
          semanticScore,
          lexicalScore,
          symbolScore,
          fieldScore,
          typeWeight,
          intentBoost,
          noisePenalty
        };
      });
    
      const maxBm25 = intermediate.reduce((max, item) => Math.max(max, item.bm25Score), 0);
    
      const results = intermediate.map(item => {
        const normalizedBm25 = maxBm25 > 0 ? item.bm25Score / maxBm25 : 0;
        const baseScore = normalizedBm25 * 0.4 + item.semanticScore * 0.2 + item.lexicalScore * 0.15 + item.symbolScore * 0.1 + item.fieldScore * 0.15;
        const weightedScore = baseScore * item.typeWeight + item.intentBoost - item.noisePenalty;
        return {
          ...item.entry,
          similarity: Math.max(0, Math.min(1, weightedScore))
        };
      });
    
      results.sort((a, b) => (b.similarity || 0) - (a.similarity || 0));
      
      return results.slice(0, limit);
    }
  • exactSearch() implementation on FileSystemIndex: tries exact method name match, class name match, qualified method (Class.Method) match, then falls back to regex search over embedding text
    async exactSearch(pattern: string): Promise<EmbeddingEntry[]> {
      if (!this.initialized) await this.initialize();
    
      const lowerPattern = pattern.toLowerCase();
    
      // 1. Exact method name match (fast path)
      const methodMatches = this.methodNameIndex.get(lowerPattern);
      if (methodMatches && methodMatches.length > 0) {
        return methodMatches.map(entry => ({ ...entry, similarity: 1 }));
      }
    
      // 2. Exact class name match
      const classMatches = this.classNameIndex.get(lowerPattern);
      if (classMatches && classMatches.length > 0) {
        return classMatches.map(entry => ({ ...entry, similarity: 1 }));
      }
    
      // 3. Full qualified method search (Class.Method)
      const dotIndex = lowerPattern.indexOf('.');
      if (dotIndex > 0) {
        const classPart = lowerPattern.substring(0, dotIndex);
        const methodPart = lowerPattern.substring(dotIndex + 1);
        const entries = this.classNameIndex.get(classPart);
        if (entries) {
          const filtered = entries.filter(e =>
            e.methodName && e.methodName.toLowerCase() === methodPart
          );
          if (filtered.length > 0) {
            return filtered.map(entry => ({ ...entry, similarity: 1 }));
          }
        }
      }
    
      // 4. Fallback to regex search over embeddings text
      const regex = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i');
      return this.embeddings
        .filter(entry => regex.test(entry.text))
        .map(entry => ({ ...entry, similarity: 1 }));
    }
Behavior2/5

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

With no annotations, the description fails to disclose read-only nature, result format, or behavior for different search types (semantic, exact, fuzzy), leaving the agent without critical behavioral cues.

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

Conciseness4/5

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

The description is a single efficient sentence with no waste, but it could briefly mention the search type and limit parameters without becoming verbose.

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?

The description omits output format, error handling, and does not fully cover the searchType and limit parameters even though schema coverage is complete; an agent may not know how to use the tool correctly.

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 coverage is 100%, so the baseline is 3. The description only restates the 'semantic description' already evident in the schema and does not add new meaning beyond the schema's parameter descriptions.

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

Purpose5/5

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

The description specifies the verb (search), resource (functions in DayZ vanilla scripts), and method (by semantic description), clearly differentiating it from sibling tools that focus on callers, usage examples, or code validation.

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?

No guidance is provided on when to use this tool versus siblings like find_callers or find_vanilla_alternative, nor are any exclusions or prerequisites mentioned.

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

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/quantumloader/dayz-api-mcp-server'

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