mcp-rubber-duck
CLAUDE.md179 starsChanged 55 days agoMITView on GitHub
MCP Rubber Duck is an MCP (Model Context Protocol) server that bridges to multiple OpenAI-compatible LLMs. It provides "rubber duck debugging" with AI - query multiple LLM providers simultaneously and get different perspectives. Configuration (src/config/) - config.ts - ConfigManager loads config from JSON file or environment variables - types.ts - Zod schemas and TypeScript types (types inferred via z.infer<>) Providers (src/providers/) - manager.ts - ProviderManager manages all LLM provider connections - provider.ts - DuckProvider wraps OpenAI SDK for individual provider…
- Reads credentials
We split this CLAUDE.md into the rules it gives an agent
11 rules. About 0 are common, 5 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 60
All tools return MCP-compliant response:
- Very specific: line 90
Add to getTools() array with JSON Schema for inputs
- Very specific: line 91
Add case to switch in CallToolRequestSchema handler
- Very specific: line 97
Add to appropriate schema (e.g., ConfigSchema)
- Distinctive: line 117
Every feature must pass before merging:
- Distinctive: line 140
Do not commit without user approval
- Distinctive: line 141
Do not add features not in the spec
- Very specific: line 142
Do not edit generated/built files in dist/ or UI build outputs
- Distinctive: line 143
Do not connect to real LLM APIs in tests — always mock provider responses
- Very specific: line 144
Do not use bare imports without .js extension
- Very specific: line 148
When completing features, closing issues, creating new issues, or working on items that appear in docs/roadmap.md, check if the roadmap …
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
MCP Rubber Duck is an MCP (Model Context Protocol) server that bridges to multiple OpenAI-compatible LLMs. It provides "rubber duck debugging" with AI - query multiple LLM providers simultaneously and get different perspectives.
Common Commands
npm run build # Build TypeScript to dist/
npm run dev # Development with watch mode
npm test # Run all tests
npm test -- tests/config.test.ts # Single test file
npm test -- --testNamePattern="should load config" # Specific test
npm run lint # ESLint
npm run format # Prettier
npm run typecheck # Type check without emit
/setup [tool] # Configure mcp-rubber-duck in an AI coding toolArchitecture
Entry Points
src/index.ts- Application entry, createsRubberDuckServerand handles process lifecyclesrc/server.ts- Main MCP server implementation (RubberDuckServerclass)
Core Layers
Configuration (src/config/)
config.ts-ConfigManagerloads config from JSON file or environment variablestypes.ts- Zod schemas and TypeScript types (types inferred viaz.infer<>)
Providers (src/providers/)
manager.ts-ProviderManagermanages all LLM provider connectionsprovider.ts-DuckProviderwraps OpenAI SDK for individual provider callsenhanced-manager.ts-EnhancedProviderManageradds MCP Bridge functionality
Services (src/services/)
conversation.ts-ConversationManagermaintains chat contexthealth.ts-HealthMonitorchecks provider availabilitymcp-client-manager.ts- Connects to external MCP servers (for MCP Bridge)approval.ts- MCP tool approval workflowconsensus.ts- Multi-agent voting and consensus logic
Tools (src/tools/)
Each file exports a tool handler function. See "Adding New Tools" below.
Key Patterns
ESM Modules
Project uses ES modules ("type": "module"). Always use .js extension in imports, even for TypeScript files:
import { ProviderManager } from '../providers/manager.js'; // Correct
import { ProviderManager } from '../providers/manager'; // WrongTool Response Format
All tools return MCP-compliant response:
return {
content: [{ type: 'text', text: 'response string' }],
};
// On error:
return {
content: [{ type: 'text', text: 'Error: ...' }],
isError: true,
};Adding New Tools
- Create
src/tools/my-tool.ts:
import { ProviderManager } from '../providers/manager.js';
export async function myTool(
providerManager: ProviderManager, // Dependencies vary per tool
args: Record<string, unknown>
) {
const { prompt } = args as { prompt?: string };
if (!prompt) throw new Error('prompt is required');
const response = await providerManager.askDuck(undefined, prompt, {});
return { content: [{ type: 'text', text: response.content }] };
}- In
src/server.ts:- Import:
import { myTool } from './tools/my-tool.js'; - Add to
getTools()array with JSON Schema for inputs - Add case to switch in
CallToolRequestSchemahandler
- Import:
Note: Tool dependencies vary - some take providerManager, others take conversationManager, healthMonitor, etc. Check existing tools for patterns.
Config Validation
Config uses Zod schemas in src/config/types.ts. When adding config options:
- Add to appropriate schema (e.g.,
ConfigSchema) - Type is automatically inferred via
z.infer<typeof ConfigSchema>
MCP Terminology
MCP_SERVER=true- This server runs AS an MCP server (for Claude Desktop)MCP_BRIDGE_ENABLED=true- Ducks can ACCESS external MCP servers as clients
Tech Stack
- Language: TypeScript 5.x (ESM,
"type": "module") - Runtime: Node.js
- Framework: MCP SDK (
@modelcontextprotocol/sdk) - Build:
tsc+ Vite (UI builds) - Testing: Jest 29 with
ts-jest(ESM via--experimental-vm-modules) - Validation: Zod (types inferred via
z.infer<>) - LLM Client: OpenAI SDK (
openai) - Logging: Winston
Gating Rule
Every feature must pass before merging:
npm run typecheck && npm run lint && npm testWorkflows
Bugfix: /debug → /implement → /gate-check → /pr
Feature: /brainstorm → /spec-write → /implement → /spec-review → /gate-check → /pr
Refactor: /implement → /simplify → /gate-check → /pr
Testing Conventions
- Framework: Jest 29 with ts-jest (ESM mode)
- Mocking:
jest.fn(),jest.spyOn(), manual mocks - File naming:
*.test.tsintests/directory - Structure:
tests/mirrorssrc/— flat for top-level modules, subdirectories forguardrails/,services/,tools/ - Coverage: Reported via Jest built-in coverage (see test output)
- Deterministic data: Fixed provider configs and mock responses in each test
DO NOT
- Do not commit without user approval
- Do not add features not in the spec
- Do not edit generated/built files in
dist/or UI build outputs - Do not connect to real LLM APIs in tests — always mock provider responses
- Do not use bare imports without
.jsextension
Roadmap
When completing features, closing issues, creating new issues, or working on items that appear in docs/roadmap.md, check if the roadmap should be updated (e.g., marking items as done, adding new items, adjusting phases or priorities). Don't update it for unrelated commits.
Environment Variables
# Provider API keys
OPENAI_API_KEY=sk-...
GEMINI_API_KEY=...
GROQ_API_KEY=gsk_...
# Defaults
DEFAULT_PROVIDER=openai
DEFAULT_TEMPERATURE=0.7
LOG_LEVEL=info # debug, info, warn, error
# MCP modes
MCP_SERVER=true # Run as MCP server
MCP_BRIDGE_ENABLED=true # Enable MCP Bridge feature
# Custom providers: CUSTOM_{NAME}_{FIELD}
CUSTOM_MYAPI_API_KEY=...
CUSTOM_MYAPI_BASE_URL=https://api.example.com/v1
CUSTOM_MYAPI_DEFAULT_MODEL=model-nameIn this repository3 other files it gives its agents.
- setup-mcp-serverSkill
- tool-reviewSkill
- update-pricingSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

