search_rules
Find specific Roller Derby rules by searching with keywords to locate relevant sections on gameplay, penalties, scoring, and officiating.
Instructions
Search Roller Derby rules by keyword
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:211-268 (handler)Handler function that searches for the given query in either the complete rules file or a specific section, extracts matching lines with surrounding context, and returns the results as JSON or a no-results message.
async (args) => { const query = args.query.toLowerCase(); const searchSection = args.section || "all"; let results = []; if (searchSection === "all") { // Search in complete file const content = await fs.readFile(COMPLETE_FILE, "utf-8"); const lines = content.split("\n"); lines.forEach((line, index) => { if (line.toLowerCase().includes(query)) { // Add context (line before and after) const context = lines .slice(Math.max(0, index - 1), Math.min(lines.length, index + 2)) .join("\n"); results.push({ line: index + 1, context: context, }); } }); } else { // Search in a specific section const filename = sectionMap[searchSection]; if (filename) { const filePath = path.join(SECTIONS_DIR, filename); const content = await fs.readFile(filePath, "utf-8"); const lines = content.split("\n"); lines.forEach((line, index) => { if (line.toLowerCase().includes(query)) { const context = lines .slice(Math.max(0, index - 1), Math.min(lines.length, index + 2)) .join("\n"); results.push({ section: searchSection, line: index + 1, context: context, }); } }); } } return { content: [ { type: "text", text: results.length > 0 ? JSON.stringify(results, null, 2) : `No results found for "${args.query}"`, }, ], }; } ); - index.js:185-210 (schema)Tool schema including description and inputSchema defining required 'query' parameter and optional 'section' with allowed values.
{ description: "Search Roller Derby rules by keyword", inputSchema: { type: "object", properties: { query: { type: "string", description: "The search term to look for in the rules", }, section: { type: "string", description: "Specific section to search in (optional)", enum: [ "introduction", "parametres", "le-jeu", "score", "penalites", "arbitrage", "all", ], }, }, required: ["query"], }, }, - index.js:182-184 (registration)Registration of the 'search_rules' tool via server.registerTool.
// Tool: search_rules server.registerTool( "search_rules",