openrouter-mcp-multimodal
AGENTS.md102 starsChanged 39 days agoApache-2.0View on GitHub
Guidance for AI coding agents (Cursor, Claude Code, Copilot, Kiro, etc.) working in openrouter-mcp-multimodal.
- Reads credentials
- Commits and pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- llms.txtllms.txt
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
14 rules. About 0 are common, 3 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
11
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
- Very specific: line 7
Run npm run ci before claiming work is done — this runs lint, format check, version sync, build, and all tests.
- Very specific: line 8
Do not commit secrets (.env, API keys).
- Distinctive: line 9
Keep imports at the top of files — no inline imports unless documented for circular deps.
- Very specific: line 10
Use exhaustive switch with never in the default case for TypeScript unions.
- Very specific: line 46
Path safety: all local file reads go through resolveSafeInputPath, all writes through resolveSafeOutputPath.
- Very specific: line 157
Create src/tool-handlers/my-tool.ts with export async function handleMyTool(...).
- Very specific: line 158
Add the tool name to TOOL_NAMES in src/tool-descriptions.ts and add its description using buildToolDescription().
- Very specific: line 159
Add the JSON schema (inputSchema, outputSchema, annotations) in src/tool-definitions.ts.
- Very specific: line 160
Add an icon entry in src/tool-icons.ts.
- Very specific: line 161
Add the dispatch case in src/tool-handlers.ts.
- Very specific: line 162
Update the test count assertion in src/__tests__/tool-descriptions.test.ts and src/__tests__/regression/regression.test.ts.
- Distinctive: line 169
Create git commits or tags unless the user asked you to release.
- Distinctive: line 171
Add inline imports unless there's a documented circular dependency reason.
- Very specific: line 172
Remove or weaken SSRF guards in fetch-utils.ts.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.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
Agent instructions
Guidance for AI coding agents (Cursor, Claude Code, Copilot, Kiro, etc.) working in openrouter-mcp-multimodal.
Before you ship
- Run
npm run cibefore claiming work is done — this runs lint, format check, version sync, build, and all tests. - Do not commit secrets (
.env, API keys). - Keep imports at the top of files — no inline imports unless documented for circular deps.
- Use exhaustive
switchwithneverin the default case for TypeScript unions.
Architecture at a glance
src/index.ts ← MCP server entry, stdio transport, .env loading
src/version.ts ← SERVER_VERSION + MCP_PROTOCOL_VERSION (must match package.json)
src/tool-handlers.ts ← Tool router: ListTools + CallTool dispatch
src/tool-definitions.ts ← Tool JSON schemas (inputSchema, outputSchema, annotations, icons)
src/tool-descriptions.ts ← TOOL_NAMES array + structured descriptions (use when / bad examples / fails when)
src/tool-icons.ts ← SVG data URI icons for each tool (MCP 2025-11-25)
src/tool-handlers/ ← Handler files (some serve multiple tools, e.g. async-chat.ts → 2 tools, generate-video.ts → 3)
src/openrouter-api.ts ← Direct HTTP client for /videos, /images, /audio/speech, /audio/transcriptions, /rerank, /embeddings, /api/alpha/decisions
src/openrouter-openai-client.ts ← OpenAI SDK configured for OpenRouter base URL
src/errors.ts ← ErrorCode taxonomy (INVALID_INPUT, UNSAFE_PATH, UPSTREAM_*, etc.)
src/logger.ts ← Stderr JSON line logger with secret redaction (stdout reserved for MCP)
src/model-cache.ts ← Shared model catalog cache with TTL, routing suffix handling, and search
src/tts-defaults.ts ← TTS default constants (model, voice, response format)Tools (21 total)
| Category | Tools |
| Chat | chat_completion, start_chat_completion, get_chat_completion_status |
| Vision | analyze_image, generate_image, generate_image_dedicated |
| Audio | analyze_audio, generate_audio, text_to_speech, speech_to_text |
| Video | analyze_video, generate_video, generate_video_from_image, get_video_status |
| Catalog | search_models, get_model_info, validate_model, rerank_documents, health_check |
| Embedding | embed_text |
| Decisions | decide |
Key patterns
- Tool definitions live in
tool-definitions.ts, descriptions intool-descriptions.ts, icons intool-icons.ts. All three must stay in sync withTOOL_NAMES. The build-time assertion intool-definitions.tscatches count mismatches. - Handlers return
{ content, _meta }for success ortoolError(ErrorCode, message)for errors. Every error carries_meta.code. - Path safety: all local file reads go through
resolveSafeInputPath, all writes throughresolveSafeOutputPath. Never bypass the sandbox. - OpenRouter API: chat/analyze tools use the OpenAI SDK via
openrouter-openai-client.ts. Video/image/audio dedicated endpoints, rerank, embeddings, and decisions use the direct HTTP client inopenrouter-api.ts. - Async tools:
start_chat_completionfires a background request and returns ajob_idimmediately.get_chat_completion_statuspolls. Video generation follows the same pattern viagenerate_video+get_video_status. - Caching:
cache,cache_ttl,cache_clearparams on tools map toX-OpenRouter-Cache*headers viacache.ts. - Provider routing:
providerparam on tools passes through to OpenRouter's routing system. Env defaults inprovider-routing.ts.
Coding style
- TypeScript strict mode, ESM (
"type": "module") - Prettier: single quotes, trailing commas, 100 char width, semicolons
- ESLint:
@typescript-eslint/recommended+ prettier config - Naming:
handleFooBarfor tool handlers,ErrorCode.SCREAMING_SNAKEfor error codes - No default exports — named exports everywhere
- Tests: Vitest. File per module at
src/__tests__/. No test unless user asks.
Testing
| Command | What it runs | When to use |
npm test | Unit tests (Vitest) | After any code change |
npm run test:regression | Regression suite | Before release |
npm run test:integration | Integration tests (may hit OpenRouter) | Before release, needs API key |
npm run test:e2e | Live E2E against real OpenRouter | Release validation |
npm run test:smoke:npm | Build → pack → install → boot | Verify npm package works |
npm run test:smoke:docker | Docker image boot test | Verify Docker image |
npm run test:smoke:uvx:local | uvx/pipx launcher test | Verify Python launcher |
npm run test:all | unit + regression + integration | Pre-release gate |
npm run ci | lint + format + version sync + build + test:all | The one command before shipping |
Current: 135 test files, 3929 tests (133 unit/mock: 3905 + 1 regression: 7 + 1 integration: 17).
Releasing (read this before publishing)
Full guide: docs/RELEASING.md
Short version
| Action | Updates npm/PyPI? | Updates Docker :latest? |
Push to main | No | No |
Merge Release Please PR → tag vX.Y.Z | Yes | Yes |
Manual git tag vX.Y.Z && git push origin vX.Y.Z | Yes | Yes |
Normal path: land conventional commits on main → merge the Release Please PR → tag is created automatically → publish.yml publishes everywhere.
Manual path: bump all version files → npm run version:check → test → commit → git tag vX.Y.Z → push tag.
Version files (must all match package.json)
package.json/package-lock.jsonsrc/version.ts(SERVER_VERSION)python/pyproject.tomlserver.json(version fields + Docker OCI tag).release-please-manifest.jsonCHANGELOG.md(release notes)
Check: npm run version:check
Commit messages for Release Please
Use Conventional Commits:
fix: …— patch releasefeat: …— minor releasefeat!: …or footerBREAKING CHANGE:— major release
Repo map
| Area | Location |
| MCP entry + handshake | src/index.ts, src/version.ts |
| Tool router | src/tool-handlers.ts |
| Tool JSON schemas + icons | src/tool-definitions.ts, src/tool-icons.ts |
| Tool descriptions | src/tool-descriptions.ts |
| Handler implementations | src/tool-handlers/*.ts |
| OpenRouter HTTP client | src/openrouter-api.ts |
| OpenAI SDK client | src/openrouter-openai-client.ts |
| Error taxonomy | src/errors.ts |
| Upstream error classifier | src/tool-handlers/openrouter-errors.ts |
| Chat request building | src/tool-handlers/chat-request.ts |
| Async chat jobs | src/tool-handlers/async-chat.ts |
| Chat completion parsing | src/tool-handlers/completion-utils.ts |
| Embeddings handler | src/tool-handlers/embed-text.ts |
| Decisions handler | src/tool-handlers/decide.ts |
| OpenAI withResponse | src/tool-handlers/openai-withresponse.ts |
| Binary result policy | src/tool-handlers/tool-result-payload.ts |
| Structured output helper | src/tool-handlers/structured-output.ts |
| Usage sanitization | src/tool-handlers/sanitize-usage.ts |
| Path sandbox | src/tool-handlers/path-safety.ts, src/tool-handlers/path-utils.ts |
| Cache headers | src/tool-handlers/cache.ts |
| Provider routing | src/tool-handlers/provider-routing.ts |
| SSRF / fetch guards | src/tool-handlers/fetch-utils.ts |
| Image pipeline | src/tool-handlers/image-utils.ts, src/tool-handlers/image-source.ts, src/tool-handlers/generate-image-input.ts |
| Video format validation | src/tool-handlers/video-utils.ts |
| Audio utilities | src/tool-handlers/audio-utils.ts |
| Structured JSON logger | src/logger.ts |
| Model catalog cache | src/model-cache.ts |
| TTS defaults | src/tts-defaults.ts |
| Tests | src/__tests__/ |
| Python uvx launcher | python/mcp_server_openrouter_multimodal/ |
| MCP registry manifest | server.json |
| Security policy | SECURITY.md |
| Strategy & vision | STRATEGY.md |
| Domain glossary | CONCEPTS.md |
| Smoke tests | scripts/smoke-*.mjs |
| CI | .github/workflows/ci.yml |
| Publish | .github/workflows/publish.yml |
| Release automation | .github/workflows/release-please.yml |
Adding a new tool
- Create
src/tool-handlers/my-tool.tswithexport async function handleMyTool(...). - Add the tool name to
TOOL_NAMESinsrc/tool-descriptions.tsand add its description usingbuildToolDescription(). - Add the JSON schema (inputSchema, outputSchema, annotations) in
src/tool-definitions.ts. - Add an icon entry in
src/tool-icons.ts. - Add the dispatch
caseinsrc/tool-handlers.ts. - Update the test count assertion in
src/__tests__/tool-descriptions.test.tsandsrc/__tests__/regression/regression.test.ts. - Run
npm run ci.
Do not
- Push to
mainand assume npm/PyPI updated — they only publish on version tags. - Bump version in only one file — CI will fail
version:check. - Create git commits or tags unless the user asked you to release.
- Bypass path sandbox (
resolveSafeInputPath/resolveSafeOutputPath) for local file access. - Add inline imports unless there's a documented circular dependency reason.
- Remove or weaken SSRF guards in
fetch-utils.ts.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

