agentleFS
stabganstabgan/openrouter-mcp-multimodal/AGENTS.md

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.

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
  1. Very specific:

    Run npm run ci before claiming work is done — this runs lint, format check, version sync, build, and all tests.

    line 7
  2. Very specific:

    Do not commit secrets (.env, API keys).

    line 8
  3. Distinctive:

    Keep imports at the top of files — no inline imports unless documented for circular deps.

    line 9
  4. Very specific:

    Use exhaustive switch with never in the default case for TypeScript unions.

    line 10
  5. Very specific:

    Path safety: all local file reads go through resolveSafeInputPath, all writes through resolveSafeOutputPath.

    line 46
  6. Very specific:

    Create src/tool-handlers/my-tool.ts with export async function handleMyTool(...).

    line 157
  7. Very specific:

    Add the tool name to TOOL_NAMES in src/tool-descriptions.ts and add its description using buildToolDescription().

    line 158
  8. Very specific:

    Add the JSON schema (inputSchema, outputSchema, annotations) in src/tool-definitions.ts.

    line 159
  9. Very specific:

    Add an icon entry in src/tool-icons.ts.

    line 160
  10. Very specific:

    Add the dispatch case in src/tool-handlers.ts.

    line 161
  11. Very specific:

    Update the test count assertion in src/__tests__/tool-descriptions.test.ts and src/__tests__/regression/regression.test.ts.

    line 162
  12. Distinctive:

    Create git commits or tags unless the user asked you to release.

    line 169
  13. Distinctive:

    Add inline imports unless there's a documented circular dependency reason.

    line 171
  14. Very specific:

    Remove or weaken SSRF guards in fetch-utils.ts.

    line 172

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Agent instructions

Guidance for AI coding agents (Cursor, Claude Code, Copilot, Kiro, etc.) working in openrouter-mcp-multimodal.

Before you ship

  1. Run npm run ci before claiming work is done — this runs lint, format check, version sync, build, and all tests.
  2. Do not commit secrets (.env, API keys).
  3. Keep imports at the top of files — no inline imports unless documented for circular deps.
  4. Use exhaustive switch with never in 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)

CategoryTools
Chatchat_completion, start_chat_completion, get_chat_completion_status
Visionanalyze_image, generate_image, generate_image_dedicated
Audioanalyze_audio, generate_audio, text_to_speech, speech_to_text
Videoanalyze_video, generate_video, generate_video_from_image, get_video_status
Catalogsearch_models, get_model_info, validate_model, rerank_documents, health_check
Embeddingembed_text
Decisionsdecide

Key patterns

  • Tool definitions live in tool-definitions.ts, descriptions in tool-descriptions.ts, icons in tool-icons.ts. All three must stay in sync with TOOL_NAMES. The build-time assertion in tool-definitions.ts catches count mismatches.
  • Handlers return { content, _meta } for success or toolError(ErrorCode, message) for errors. Every error carries _meta.code.
  • Path safety: all local file reads go through resolveSafeInputPath, all writes through resolveSafeOutputPath. 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 in openrouter-api.ts.
  • Async tools: start_chat_completion fires a background request and returns a job_id immediately. get_chat_completion_status polls. Video generation follows the same pattern via generate_video + get_video_status.
  • Caching: cache, cache_ttl, cache_clear params on tools map to X-OpenRouter-Cache* headers via cache.ts.
  • Provider routing: provider param on tools passes through to OpenRouter's routing system. Env defaults in provider-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: handleFooBar for tool handlers, ErrorCode.SCREAMING_SNAKE for error codes
  • No default exports — named exports everywhere
  • Tests: Vitest. File per module at src/__tests__/. No test unless user asks.

Testing

CommandWhat it runsWhen to use
npm testUnit tests (Vitest)After any code change
npm run test:regressionRegression suiteBefore release
npm run test:integrationIntegration tests (may hit OpenRouter)Before release, needs API key
npm run test:e2eLive E2E against real OpenRouterRelease validation
npm run test:smoke:npmBuild → pack → install → bootVerify npm package works
npm run test:smoke:dockerDocker image boot testVerify Docker image
npm run test:smoke:uvx:localuvx/pipx launcher testVerify Python launcher
npm run test:allunit + regression + integrationPre-release gate
npm run cilint + format + version sync + build + test:allThe 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

ActionUpdates npm/PyPI?Updates Docker :latest?
Push to mainNoNo
Merge Release Please PR → tag vX.Y.ZYesYes
Manual git tag vX.Y.Z && git push origin vX.Y.ZYesYes

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.json
  • src/version.ts (SERVER_VERSION)
  • python/pyproject.toml
  • server.json (version fields + Docker OCI tag)
  • .release-please-manifest.json
  • CHANGELOG.md (release notes)

Check: npm run version:check

Commit messages for Release Please

Use Conventional Commits:

  • fix: … — patch release
  • feat: … — minor release
  • feat!: … or footer BREAKING CHANGE: — major release

Repo map

AreaLocation
MCP entry + handshakesrc/index.ts, src/version.ts
Tool routersrc/tool-handlers.ts
Tool JSON schemas + iconssrc/tool-definitions.ts, src/tool-icons.ts
Tool descriptionssrc/tool-descriptions.ts
Handler implementationssrc/tool-handlers/*.ts
OpenRouter HTTP clientsrc/openrouter-api.ts
OpenAI SDK clientsrc/openrouter-openai-client.ts
Error taxonomysrc/errors.ts
Upstream error classifiersrc/tool-handlers/openrouter-errors.ts
Chat request buildingsrc/tool-handlers/chat-request.ts
Async chat jobssrc/tool-handlers/async-chat.ts
Chat completion parsingsrc/tool-handlers/completion-utils.ts
Embeddings handlersrc/tool-handlers/embed-text.ts
Decisions handlersrc/tool-handlers/decide.ts
OpenAI withResponsesrc/tool-handlers/openai-withresponse.ts
Binary result policysrc/tool-handlers/tool-result-payload.ts
Structured output helpersrc/tool-handlers/structured-output.ts
Usage sanitizationsrc/tool-handlers/sanitize-usage.ts
Path sandboxsrc/tool-handlers/path-safety.ts, src/tool-handlers/path-utils.ts
Cache headerssrc/tool-handlers/cache.ts
Provider routingsrc/tool-handlers/provider-routing.ts
SSRF / fetch guardssrc/tool-handlers/fetch-utils.ts
Image pipelinesrc/tool-handlers/image-utils.ts, src/tool-handlers/image-source.ts, src/tool-handlers/generate-image-input.ts
Video format validationsrc/tool-handlers/video-utils.ts
Audio utilitiessrc/tool-handlers/audio-utils.ts
Structured JSON loggersrc/logger.ts
Model catalog cachesrc/model-cache.ts
TTS defaultssrc/tts-defaults.ts
Testssrc/__tests__/
Python uvx launcherpython/mcp_server_openrouter_multimodal/
MCP registry manifestserver.json
Security policySECURITY.md
Strategy & visionSTRATEGY.md
Domain glossaryCONCEPTS.md
Smoke testsscripts/smoke-*.mjs
CI.github/workflows/ci.yml
Publish.github/workflows/publish.yml
Release automation.github/workflows/release-please.yml

Adding a new tool

  1. Create src/tool-handlers/my-tool.ts with export async function handleMyTool(...).
  2. Add the tool name to TOOL_NAMES in src/tool-descriptions.ts and add its description using buildToolDescription().
  3. Add the JSON schema (inputSchema, outputSchema, annotations) in src/tool-definitions.ts.
  4. Add an icon entry in src/tool-icons.ts.
  5. Add the dispatch case in src/tool-handlers.ts.
  6. Update the test count assertion in src/__tests__/tool-descriptions.test.ts and src/__tests__/regression/regression.test.ts.
  7. Run npm run ci.

Do not

  • Push to main and 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.