agentleFS
vaaynevaayne/mcphub/AGENTS.md

mcphub

AGENTS.md2 starsChanged 11 months agoMITView on GitHub

Server mode (mh serve -c config.json): Starts an MCP hub server that aggregates multiple backend servers. AI clients connect to the hub. CLI mode (mh list, mh inspect, mh invoke, mh exec): Interact with MCP servers directly from terminal. Flags come after the subcommand: -c for config file, -u for remote URL, or --stdio for subprocess. Skill mode: Two workflows for extending agent capabilities: Server and CLI modes share connection logic in internal/cli/ (config_client, remote, stdio_client). Server mode flow: CLI…

  • 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 repository2 other files it gives its agents.

The file

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

10 rules. About 0 are common, 0 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Generate skills: Use mcp-skill-gen workflow to create skill files from MCP servers.

    line 42
  2. Very specific:

    Start MCP server on stdio/http/sse, expose aggregated tools → internal/server/

    line 53
  3. Very specific:

    Create appropriate client → internal/cli/{config_client,remote,stdio_client}.go

    line 59
  4. Very specific:

    Tool namespacing: All backend tools are prefixed with server name in camelCase to avoid conflicts (githubSearch not search)

    line 67
  5. Very specific:

    All non-main packages live in internal/ (not importable externally)

    line 75
  6. Very specific:

    Every package should have *_test.go files with meaningful coverage

    line 76
  7. Very specific:

    Use structured logging via internal/logging - no fmt.Println for runtime messages

    line 77
  8. Very specific:

    Adding a new CLI command: Create file in internal/cli/, register in main.go

    line 93
  9. Very specific:

    Adding a built-in tool: Add to internal/tools/builtin.go, implement handler, add tests

    line 95
  10. Very specific:

    Modifying config schema: Update structs in internal/config/config.go, add validation, update tests

    line 99

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

MCP Hub Agent Instructions

Naming Convention

  • Product name: MCP Hub (for docs and display)
  • CLI command: mh (following the gh pattern)
  • Go module: mcphub

Commands

mise run build    # Build binary to bin/mh
mise run test     # Run all tests with coverage
mise run run      # Build and run with example config
mise run format   # Format code (go fmt, go mod tidy)

Project Structure

main.go                    # CLI entry point (cobra)
internal/
├── cli/                   # Subcommands: serve, list, inspect, invoke, exec, update
├── server/                # MCP hub server - aggregates tools, handles requests
├── client/                # Remote MCP client manager - connections, reconnection logic
├── config/                # Configuration loading and validation
├── tools/                 # Built-in tools: search, execute, refreshTools
├── js/                    # Goja JavaScript runtime for execute tool
├── transport/             # Transport factory: stdio, http, sse
└── logging/               # Structured logging with zap

Three Modes

Server mode (mh serve -c config.json): Starts an MCP hub server that aggregates multiple backend servers. AI clients connect to the hub.

CLI mode (mh list, mh inspect, mh invoke, mh exec): Interact with MCP servers directly from terminal. Flags come after the subcommand: -c for config file, -u for remote URL, or --stdio for subprocess.

Skill mode: Two workflows for extending agent capabilities:

  • Discover skills: mh skills find/add to browse and install from skills.sh
  • Generate skills: Use mcp-skill-gen workflow to create skill files from MCP servers. AI agents read the skill, then use mh CLI to discover/invoke tools on-demand. Keeps context small while accessing hundreds of tools.

Server and CLI modes share connection logic in internal/cli/ (config_client, remote, stdio_client).

Architecture Overview

Server mode flow:

  1. Load and validate config → internal/config/
  2. Connect to each MCP server (stdio subprocess or http/sse client) → internal/client/ + internal/transport/
  3. Discover tools from each server, namespace them (camelCase: serverNameToolName)
  4. Start MCP server on stdio/http/sse, expose aggregated tools → internal/server/
  5. Route incoming tool calls to appropriate backend, return results

CLI mode flow:

  1. Parse connection source (config/url/stdio) → internal/cli/helpers.go
  2. Create appropriate client → internal/cli/{config_client,remote,stdio_client}.go
  3. Execute command (list/inspect/invoke) using internal/tools/ core functions
  4. Format and print output

Built-in tools (search, execute, refreshTools) are registered in internal/tools/ and don't go through backends.

Key Design Decisions

  • Tool namespacing: All backend tools are prefixed with server name in camelCase to avoid conflicts (githubSearch not search)
  • Sync-only JS: The execute tool blocks async to prevent complexity and security issues (no Promises, no setTimeout)
  • Transport abstraction: internal/transport/ provides unified interface for stdio/http/sse so client code doesn't care about transport type
  • Fail-open by default: Servers with required: false (default) won't block hub startup if they fail to connect

Code Style

  • Go 1.23+, standard gofmt formatting
  • All non-main packages live in internal/ (not importable externally)
  • Every package should have *_test.go files with meaningful coverage
  • Use structured logging via internal/logging - no fmt.Println for runtime messages
  • Error messages should be lowercase, no trailing punctuation
  • Context should flow through all blocking operations

Testing

go test ./...                    # Run all tests
go test -cover ./...             # With coverage
go test -v ./internal/js         # Verbose, specific package

For integration tests, see docs/testing.md which documents the built-in test server.

Common Tasks

Adding a new CLI command: Create file in internal/cli/, register in main.go

Adding a built-in tool: Add to internal/tools/builtin.go, implement handler, add tests

Supporting new transport: Implement Transport interface in internal/transport/, register in factory

Modifying config schema: Update structs in internal/config/config.go, add validation, update tests

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.