find_usage_examples
Retrieve real usage examples of a function in vanilla DayZ scripts by providing the class and method name.
Instructions
Find real usage examples of a function from vanilla DayZ scripts
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| className | Yes | Class name | |
| methodName | Yes | Method name | |
| limit | No | Number of examples (default 3) |
Implementation Reference
- src/indexer/FileSystemIndex.ts:363-385 (handler)The actual implementation of findUsageExamples. It iterates over all embedding entries (indexed methods), checks if the entry matches the given className+methodName by comparing fully-qualified name or substring/text match, and returns up to `limit` results.
findUsageExamples(className: string, methodName: string, limit: number = 3): EmbeddingEntry[] { const methodNameLower = methodName.toLowerCase(); const fqMethod = `${className.toLowerCase()}.${methodNameLower}`; const results: EmbeddingEntry[] = []; for (const entry of this.embeddings) { if (entry.type !== 'method') continue; const methodText = entry.text.toLowerCase(); const entryClass = (entry.className || '').toLowerCase(); const entryMethod = (entry.methodName || '').toLowerCase(); const entryFq = `${entryClass}.${entryMethod}`; if (entryFq === fqMethod || methodText.includes(fqMethod) || entryMethod === methodNameLower) { results.push({ ...entry, similarity: entryFq === fqMethod ? 1 : 0.75 }); } } return results.slice(0, limit); } - src/server/DayZMCP.ts:34-38 (schema)Zod schema for the 'find_usage_examples' tool input: className (string), methodName (string), limit (number 1-10, default 3).
const FindUsageExamplesSchema = z.object({ className: z.string().describe('Class name'), methodName: z.string().describe('Method name'), limit: z.number().min(1).max(10).default(3) }); - src/server/DayZMCP.ts:138-159 (registration)Tool registration in the ListToolsRequestSchema handler: declares the tool with name 'find_usage_examples', description, and JSON Schema input definition.
{ name: 'find_usage_examples', description: 'Find real usage examples of a function from vanilla DayZ scripts', inputSchema: { type: 'object', properties: { className: { type: 'string', description: 'Class name' }, methodName: { type: 'string', description: 'Method name' }, limit: { type: 'number', description: 'Number of examples (default 3)' } }, required: ['className', 'methodName'] } }, - src/server/DayZMCP.ts:328-353 (registration)Tool invocation handler in CallToolRequestSchema: parses args with FindUsageExamplesSchema, calls this.index.findUsageExamples(), and formats the response.
case 'find_usage_examples': { const args = FindUsageExamplesSchema.parse(request.params.arguments); const examples = this.index.findUsageExamples(args.className, args.methodName, args.limit); return { content: [ { type: 'text', text: JSON.stringify({ className: args.className, methodName: args.methodName, count: examples.length, examples: examples.map(e => ({ id: e.id, type: e.type, className: e.className, methodName: e.methodName, snippet: e.text.substring(0, 260), similarity: e.similarity })) }, null, 2) } ] }; } - src/indexer/Indexer.ts:26-26 (helper)Interface declaration of findUsageExamples in the Indexer interface, defining the contract for the method signature.
findUsageExamples(className: string, methodName: string, limit?: number): EmbeddingEntry[];