agentleFS
1mcp-app1mcp-app/agent/AGENTS.md

agent

AGENTS.md513 starsChanged 15 months agoApache-2.0View on GitHub

Use the repository's existing test framework, fixtures, and required quality gates. Diagnose failed checks and complete unaffected work. Report unresolved gates accurately; do not waive them or claim verification succeeded. "Verify" and "confirm" mean checking evidence unless an instruction explicitly requests human approval. 1MCP is a unified MCP server that aggregates multiple MCP servers into one endpoint. It acts as a proxy, managing servers as subprocesses and forwarding requests from AI assistants.

  • Reads credentials
  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 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

We split this AGENTS.md into the rules it gives an agent

10 rules. About 0 are common, 3 are distinctive, and 7 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.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use the repository's existing test framework, fixtures, and required quality gates.

    line 46
  2. Very specific:

    Keep ordinary two-way if/else when it is clearer.

    line 103
  3. Very specific:

    Test isolation: Use ONE_MCP_CONFIG_DIR=.tmp-test for MCP command testing

    line 116
  4. Very specific:

    Mock data: Use test/unit-utils/MockFactories.ts for consistent patterns

    line 117
  5. Distinctive:

    Use Zod schemas for all input validation and API boundaries

    line 121
  6. Very specific:

    Use debugIf(), infoIf(), warnIf() for performance-critical hot paths:

    line 126
  7. Very specific:

    When adding new commands, follow the pattern in src/commands/:

    line 144
  8. Distinctive:

    Create command file with yargs builder and handler

    line 146
  9. Very specific:

    Add unit tests (co-located .test.ts)

    line 147
  10. Very specific:

    Add E2E tests in test/e2e/ if needed

    line 148

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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

AGENTS.md

Repository Information

Development Commands

# Setup
pnpm install
cp .env.example .env  # Required for development

# Build & Run
pnpm build            # Build the project
pnpm dev              # Development with auto-rebuild
pnpm watch            # Watch mode for development

# Quality Checks (run before committing)
pnpm lint && pnpm typecheck && pnpm build && pnpm test:unit

# Testing
pnpm test:unit                              # Run all unit tests
pnpm test:unit src/config/mcpConfigManager.test.ts  # Run single test file
pnpm test:unit -t "ServerManager"           # Run tests matching name pattern (-t = --testNamePattern)
pnpm test:unit:watch                        # Watch mode
pnpm test:unit:coverage                     # With coverage
pnpm test:e2e                               # E2E tests (sequential, with fixtures)
pnpm test:e2e:watch                         # E2E watch mode

# Debug
pnpm inspector                              # MCP Inspector

# Documentation
pnpm docs:dev         # Start VitePress dev server
pnpm docs:build       # Build documentation (run after doc changes)

# Binary
pnpm sea:build        # Create SEA bundle
pnpm sea:binary       # Build binary for current platform

Verification and completion

Use the repository's existing test framework, fixtures, and required quality gates. Diagnose failed checks and complete unaffected work. Report unresolved gates accurately; do not waive them or claim verification succeeded. "Verify" and "confirm" mean checking evidence unless an instruction explicitly requests human approval.

Architecture Overview

1MCP is a unified MCP server that aggregates multiple MCP servers into one endpoint. It acts as a proxy, managing servers as subprocesses and forwarding requests from AI assistants.

Layered Architecture

src/
├── commands/           # CLI commands (yargs-based)
├── transport/          # HTTP/SSE and STDIO protocol implementations
│   └── http/
│       ├── routes/     # Endpoint handlers (oauth, sse, streamable)
│       └── middlewares/# Security, auth, tag extraction
├── core/               # Business logic
│   ├── server/         # ServerManager - lifecycle management
│   ├── capabilities/   # Tool/resource aggregation
│   ├── loading/        # mcpLoadingManager, parallelExecutor, state tracking
│   └── filtering/      # Request filtering
├── config/             # McpConfigManager with hot-reload
├── auth/               # OAuth 2.1 with scope-based authorization
├── domains/            # Self-contained business domains
│   ├── preset/             # Preset management
│   ├── backup/             # Backup management
│   ├── discovery/          # App discovery
│   ├── installation/       # App installation
│   ├── registry/           # Server registry
│   ├── server-management/  # Server management
│   └── config-change/      # Config mutation/reload observation
├── application/        # Cross-cutting services (health, config reload)
└── logger/             # Winston-based conditional logging

Key Design Patterns

  • Singleton Pattern: ServerManager.getInstance(), McpConfigManager.getInstance(), AgentConfigManager.getInstance()
  • Factory Pattern: TransportFactory creates protocol-specific transports
  • Proxy Pattern: 1MCP aggregates multiple MCP servers through unified interface

Key Files

PurposeLocation
Entry Pointsrc/index.ts
Server Lifecyclesrc/core/server/ServerManager.ts
Config Managementsrc/config/mcpConfigManager.ts
Transport Factorysrc/transport/transportFactory.ts
Async Loadingsrc/core/capabilities/asyncLoadingOrchestrator.ts
Mock Factoriestest/unit-utils/MockFactories.ts

Development Conventions

Maintainable control flow

  • Make each branch express one decision. Prefer guard clauses and early returns over nested if/else chains.
  • Split conditions that mix several concerns or require mentally unpacking &&, ||, and negation. Use sequential checks or a well-named domain predicate; keep the predicate itself straightforward.
  • Keep ordinary two-way if/else when it is clearer. Avoid nested ternaries and boolean flags that make one function perform different workflows.
  • Extract small functions around meaningful decisions or steps, not wrappers that merely hide a complicated expression. Do not replace simple branches with unnecessary dispatch tables, classes, or abstractions.
  • During refactoring, preserve validation, short-circuit order, side effects, and failure behavior. Review new or changed code against these rules and verify the affected behavior.

Environment Variables

  • Access through yargs options (ONE_MCP_* prefix auto-loaded), never direct process.env access
  • Key dev settings in .env: ONE_MCP_LOG_LEVEL=debug, ONE_MCP_PORT=3051, ONE_MCP_CONFIG_DIR=./config

Testing

  • Unit tests: Co-located .test.ts files with source code
  • E2E tests: test/e2e/ with dedicated fixtures in test/e2e/fixtures/
  • Test isolation: Use ONE_MCP_CONFIG_DIR=.tmp-test for MCP command testing
  • Mock data: Use test/unit-utils/MockFactories.ts for consistent patterns

Validation

  • Use Zod schemas for all input validation and API boundaries
  • Schema validation runs before configuration changes are applied

Conditional Logging

Use debugIf(), infoIf(), warnIf() for performance-critical hot paths:

// Good: Expensive operations use callback form
debugIf(() => ({
  message: `Processing ${items.length} items`,
  meta: { itemIds: items.map((i) => i.id) },
}));

// Good: Simple messages use string form
debugIf('Cache hit');

// Bad: Simple messages don't need callback
debugIf(() => ({ message: 'Simple message' })); // Use logger.debug() instead

CLI Development

When adding new commands, follow the pattern in src/commands/:

  1. Create command file with yargs builder and handler
  2. Add unit tests (co-located .test.ts)
  3. Add E2E tests in test/e2e/ if needed
  4. Update help text

Testing MCP Commands

# Isolated testing with temporary config
ONE_MCP_CONFIG_DIR=.tmp-test node build/index.js mcp add test-server -- echo '{"jsonrpc":"2.0"}'

# HTTP transport testing
curl "http://localhost:3050/mcp?app=cursor&tags=filesystem,search"

# STDIO transport with tag filtering
echo '{"jsonrpc":"2.0","method":"initialize","params":{}}' | node build/index.js --transport stdio --tag-filter filesystem

Technology Stack

  • Runtime: Node.js with child_process APIs for server management
  • Framework: Express.js with SSE support
  • CLI: Yargs with comprehensive command parsing
  • Validation: Zod schemas
  • Logging: Winston with conditional logging
  • Testing: Vitest with V8 coverage
  • Build: esbuild for SEA bundles, tsc for development

Agent skills

Issue tracker

Issues and PRDs are tracked in GitHub Issues for 1mcp-app/agent. See docs/agents/issue-tracker.md.

Triage labels

Triage uses GitHub labels, with needs-info mapped to question and the other canonical roles using their default names. See docs/agents/triage-labels.md.

Domain docs

This repo uses a single-context layout with root CONTEXT.md and docs/adr/. See docs/agents/domain.md.

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.