search_rules
Find specific Roller Derby rules by entering 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 | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- index.js:211-267 (handler)Handler function that searches for the query in either the complete rules file or a specific section, providing matching lines with context, and returns JSON results or 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:188-209 (schema)Input schema for the search_rules tool, requiring a 'query' string and optionally a 'section' from predefined enums.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:183-268 (registration)Registration of the search_rules tool on the MCP server, including name, description, input schema, and handler reference.server.registerTool( "search_rules", { 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"], }, }, 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}"`, }, ], }; } );