agentleFS
streamnativestreamnative/streamnative-mcp-server/AGENTS.md

streamnative-mcp-server

AGENTS.md24 starsChanged 10 months agoApache-2.0View on GitHub

  • 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 33,398 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

Show its rules and text

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

13 rules. About 0 are common, 6 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

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

    Use these when you add files or touch headers.

    line 106
  2. Very specific:

    If you touch charts/, cmd/snmcp-e2e/, or scripts/e2e-test.sh, also run:

    line 109
  3. Distinctive:

    Prefer small, reviewable changes that preserve the current builder-and-wrapper architecture.

    line 162
  4. Very specific:

    Keep feature gating aligned with pkg/mcp/features.go.

    line 164
  5. Distinctive:

    Put tests next to the code they validate.

    line 166
  6. Distinctive:

    If you change public CLI flags, startup behavior, feature names, or connection examples, update README.md.

    line 167
  7. Very specific:

    If you change a runtime-visible tool, update the matching file in docs/tools/.

    line 168
  8. Very specific:

    If you change Helm values, update charts/snmcp/README.md and template assumptions together.

    line 169
  9. Very specific:

    If you change MCP protocol handling, authentication flows, or multi-session behavior, update the relevant design notes under agents/ when …

    line 170
  10. Distinctive:

    When the change touches the chart or E2E harness:

    line 202
  11. Distinctive:

    Do not mark work complete while these checks are still failing.

    line 208
  12. Very specific:

    Use Conventional Commits such as feat:, fix:, docs:, or refactor:.

    line 214
  13. Distinctive:

    If a deeper AGENTS.md is added later, it overrides this file for its subtree.

    line 224

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

Guide for autonomous coding agents working in streamnative-mcp-server.


1 | Project Snapshot

  • What it is: A Go-based Model Context Protocol (MCP) server that exposes StreamNative Cloud, Apache Kafka, and Apache Pulsar operations through one MCP surface.
  • Primary binary: bin/snmcp, built from cmd/streamnative-mcp-server/main.go.
  • Server modes: stdio and sse.
  • Current stack: Go 1.25.12, cobra, mark3labs/mcp-go, Docker, Helm, GoReleaser.
  • Published container names: streamnative/mcp-server and streamnative/snmcp.

2 | Repository Map

PathPurposeNotes
cmd/streamnative-mcp-server/Root CLI entrypointOwns the snmcp command and top-level Cobra wiring
cmd/snmcp-e2e/Go E2E clientUsed by chart and SSE authentication end-to-end tests
pkg/cmd/mcp/Transport/bootstrap layerCompletes config, creates sessions, starts stdio or sse servers
pkg/mcp/Core MCP server logicFeature flags, prompts, context tools, wrapper registration, runtime instructions
pkg/mcp/internal/context/Session/context plumbingReuse these typed context helpers instead of introducing parallel context-key patterns
pkg/mcp/builders/kafka/Kafka tool buildersPreferred home for Kafka MCP tool schemas and handlers
pkg/mcp/builders/pulsar/Pulsar tool buildersPreferred home for Pulsar MCP tool schemas and handlers
pkg/mcp/session/Multi-session Pulsar supportSSE bearer-token session cache and eviction logic
pkg/config/CLI/config resolutionStreamNative Cloud, external Kafka, external Pulsar options
pkg/kafka/, pkg/pulsar/, pkg/auth/, pkg/schema/Service/session/auth/schema helpersTouch carefully; these support the tool layer
docs/tools/Tool-facing Markdown docsThese docs are surfaced to MCP clients at runtime
agents/Design notes and MCP proposalsReview when changing protocol, auth, compliance, or multi-session behavior
charts/snmcp/Helm chartDeploys SSE mode with multi-session Pulsar support
charts/snmcp/e2e/Chart test fixturesTest tokens, local values, and auth fixtures for E2E
scripts/e2e-test.shLocal chart E2E harnessUses Docker, Kind, Helm, kubectl, and cmd/snmcp-e2e
sdk/sdk-apiserver/Local generated SDK moduleReferenced via replace in root go.mod
sdk/sdk-kafkaconnect/Local generated SDK moduleOpenAPI-generated code; avoid casual hand-edits
.github/workflows/CI pipelinesUnit tests, lint, GoReleaser, chart E2E

3 | Current Architecture Notes

  • cmd/streamnative-mcp-server/main.go creates the root snmcp command, adds shared config flags, and attaches stdio and sse subcommands.
  • pkg/cmd/mcp/mcp.go selects one runtime mode:
    • --key-file => StreamNative Cloud mode. This defaults to all features, or forces streamnative-cloud into the selected feature set.
    • --use-external-kafka => Kafka-only mode. Extra feature flags are rejected and Kafka admin/client features are inferred automatically.
    • --use-external-pulsar => Pulsar-only mode. Extra feature flags are rejected and all-pulsar is inferred automatically.
  • Most CLI flags are also exposed through SNMCP_* environment variables. The default local state/config directory is ~/.snmcp unless --config-dir or SNMCP_CONFIG_DIR overrides it.
  • pkg/mcp/server.go wraps the underlying mark3labs/mcp-go server and applies the default MCP capabilities, recovery, and logging options.
  • pkg/cmd/mcp/server.go is the current tool registration hub. It wires sessions, builds the MCP server, and registers each tool family.
  • Request-scoped Kafka, Pulsar, and StreamNative Cloud sessions flow through pkg/mcp/internal/context/ctx.go. Reuse these helpers instead of creating new ad hoc context keys.
  • The pkg/mcp/*_tools.go files are mostly registration wrappers. The actual tool schemas and handlers live in pkg/mcp/builders/....
  • New Kafka and Pulsar MCP tool work should follow the builder pattern under pkg/mcp/builders/{kafka,pulsar}. Do not create a new pkg/tools/... tree.
  • StreamNative Cloud resource and log tools are still registered from pkg/mcp/streamnative_*_tools.go; pkg/mcp/builders/streamnative/ exists but is not the active implementation path today.
  • pkg/cmd/mcp/sse.go exposes the SSE endpoint, message endpoint, and unauthenticated health probes:
    • <httpPath>/sse
    • <httpPath>/message
    • <httpPath>/healthz
    • <httpPath>/readyz
  • Multi-session Pulsar mode only exists for sse with external Pulsar. It uses bearer tokens and the cache in pkg/mcp/session/.
  • pkg/mcp/pftools/ and pkg/mcp/pulsar_functions_as_tools.go dynamically expose deployed Pulsar Functions as MCP tools. Changes here affect runtime-generated tool surfaces and should be reviewed carefully.
  • Functions-as-tools runtime behavior is also shaped by FUNCTIONS_AS_TOOLS_* environment variables. Treat changes there as runtime-surface changes, not just internal refactors.
  • Logging currently uses logrus, not zap.

4 | Required Local Workflow

Agents should match the current repository workflow, not a generic Go template.

  1. Dependencies
    go mod verify
    go mod download
  2. Formatting and module hygiene
    go fmt ./...
    go mod tidy
    Both commands are enforced by CI and must leave no diff behind.
  3. Lint
    golangci-lint run --timeout=3m
    CI currently installs golangci-lint v2.7.2.
  4. Tests
    go test -race ./...
  5. Build
    make build
    This builds bin/snmcp with version, commit, and build-date ldflags. It is a host build only; cross-platform packaging is handled by GoReleaser.
  6. License headers
    make license-check
    make license-fix
    Use these when you add files or touch headers. The repo uses license-eye, not go-licenser.
  7. Chart / E2E changes If you touch charts/**, cmd/snmcp-e2e/**, or scripts/e2e-test.sh, also run:
    ./scripts/e2e-test.sh all
    This requires Docker, Kind, Helm, and kubectl.
  8. Release-related changes For changes that affect packaging, Docker images, or release metadata, also run:
    goreleaser release --snapshot --clean
    GoReleaser also runs go mod tidy and go generate ./... in before.hooks, so run go generate ./... locally when you touch generated inputs or release plumbing.

5 | Local Runbook

# Build
make build

# StreamNative Cloud over stdio
bin/snmcp stdio --organization "$ORG" --key-file /path/to/key.json

# External Kafka over stdio
bin/snmcp stdio --use-external-kafka --kafka-bootstrap-servers localhost:9092

# External Pulsar over stdio
bin/snmcp stdio --use-external-pulsar --pulsar-web-service-url http://localhost:8080

# SSE mode
bin/snmcp sse --http-addr :9090 --http-path /mcp --organization "$ORG" --key-file /path/to/key.json

# SSE multi-session Pulsar mode
bin/snmcp sse \
  --http-addr :9090 \
  --http-path /mcp \
  --use-external-pulsar \
  --pulsar-web-service-url http://localhost:8080 \
  --multi-session-pulsar

For chart-based local development:

helm install snmcp ./charts/snmcp \
  --set pulsar.webServiceURL=http://pulsar.example.com:8080

6 | Coding Conventions For This Repo

  • Prefer small, reviewable changes that preserve the current builder-and-wrapper architecture.
  • Wrap errors with context using %w.
  • Keep feature gating aligned with pkg/mcp/features.go.
  • Respect --read-only behavior. Write-capable tools must not leak into read-only mode.
  • Put tests next to the code they validate. Builder packages already contain unit and parity tests; extend those patterns instead of inventing a separate layout.
  • If you change public CLI flags, startup behavior, feature names, or connection examples, update README.md.
  • If you change a runtime-visible tool, update the matching file in docs/tools/.
  • If you change Helm values, update charts/snmcp/README.md and template assumptions together.
  • If you change MCP protocol handling, authentication flows, or multi-session behavior, update the relevant design notes under agents/ when the current design docs would become stale.
  • Generated SDK directories are local modules. Prefer regenerating from source specs/config rather than manually editing generated files unless you are making a deliberate patch.
  • .golangci.yml enables gofmt and goimports, but CI explicitly checks go fmt ./..., go mod tidy, and golangci-lint run. Keep your local workflow aligned with those concrete commands.

7 | Common Tasks

TaskExpected steps
Add or extend an MCP toolImplement or update the builder in pkg/mcp/builders/{kafka,pulsar}; wire or update the wrapper in pkg/mcp/*_tools.go if needed; update pkg/mcp/features.go when feature gates change; add or update tests; update docs/tools/<tool>.md
Change CLI or configuration flowUpdate pkg/config/, pkg/cmd/mcp/, and any affected README examples; verify mode-selection rules still make sense
Change SSE or auth/session behaviorReview pkg/cmd/mcp/sse.go, pkg/mcp/session/, pkg/mcp/internal/context/, cmd/snmcp-e2e/, scripts/e2e-test.sh, charts/snmcp/templates/, and the relevant design docs in agents/ together
Change Helm chart behaviorUpdate values.yaml, templates, and charts/snmcp/README.md together; rerun the E2E harness
Change generated SDKsUpdate the relevant source spec/config, regenerate, keep the root replace directives valid, and avoid partial manual edits
Change protocol/auth design docsKeep the matching documents in agents/ aligned with the implemented behavior; do not leave architecture or compliance notes describing superseded flows
Release prepCheck .goreleaser.yaml, Dockerfile.goreleaser, Docker image naming, Homebrew handoff, and run go generate ./... plus goreleaser release --snapshot --clean

8 | Programmatic Checks To Run Before Finishing

go mod verify
go mod download
go fmt ./...
go mod tidy
golangci-lint run --timeout=3m
go test -race ./...
make build

When the change touches the chart or E2E harness:

./scripts/e2e-test.sh all

Do not mark work complete while these checks are still failing.


9 | Commit And PR Expectations

  • Use Conventional Commits such as feat:, fix:, docs:, or refactor:.
  • Open PRs against main unless a release branch is explicitly requested.
  • Include a short summary, a concrete testing section, and a docs-updated note.
  • Mention any affected feature flags, CLI flags, SSE paths, or Helm values so reviewers know what to smoke-test.

10 | Scope

  • This file applies to the entire repository.
  • If a deeper AGENTS.md is added later, it overrides this file for its subtree.
  • Direct user instructions still take precedence.

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.