|
| 1 | +#!/usr/bin/env node |
| 2 | +// Ponytail MCP server: serves the lazy-senior-dev ruleset over stdio as a |
| 3 | +// prompt (user-invoked) and a tool (for hosts that pull context via tools). |
| 4 | +// It does NOT replace the always-on adapters; it's the clean option for hosts |
| 5 | +// whose only injection point is the prompt menu (see #70). |
| 6 | +import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; |
| 7 | +import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; |
| 8 | +import { z } from "zod"; |
| 9 | + |
| 10 | +import { MODES, buildInstructions, resolveMode } from "./instructions.js"; |
| 11 | + |
| 12 | +const server = new McpServer({ name: "ponytail", version: "0.1.0" }); |
| 13 | + |
| 14 | +const modeArg = z |
| 15 | + .enum(MODES) |
| 16 | + .optional() |
| 17 | + .describe("Ponytail intensity: lite, full, or ultra. Omit for the configured default."); |
| 18 | + |
| 19 | +server.registerPrompt( |
| 20 | + "ponytail", |
| 21 | + { |
| 22 | + title: "Ponytail mode", |
| 23 | + description: "Lazy senior dev instructions: YAGNI, stdlib first, the smallest correct change.", |
| 24 | + argsSchema: { mode: modeArg }, |
| 25 | + }, |
| 26 | + ({ mode }) => ({ |
| 27 | + messages: [{ role: "user", content: { type: "text", text: buildInstructions(mode) } }], |
| 28 | + }), |
| 29 | +); |
| 30 | + |
| 31 | +server.registerTool( |
| 32 | + "ponytail_instructions", |
| 33 | + { |
| 34 | + title: "Ponytail instructions", |
| 35 | + description: "Return the Ponytail ruleset for the given intensity (lite, full, or ultra).", |
| 36 | + inputSchema: { mode: modeArg }, |
| 37 | + outputSchema: { mode: z.string(), instructions: z.string() }, |
| 38 | + annotations: { readOnlyHint: true, openWorldHint: false }, |
| 39 | + }, |
| 40 | + ({ mode }) => { |
| 41 | + const resolvedMode = resolveMode(mode); |
| 42 | + const instructions = buildInstructions(resolvedMode); |
| 43 | + const structuredContent = { mode: resolvedMode, instructions }; |
| 44 | + return { content: [{ type: "text", text: instructions }], structuredContent }; |
| 45 | + }, |
| 46 | +); |
| 47 | + |
| 48 | +await server.connect(new StdioServerTransport()); |
0 commit comments