Skip to content

Commit 7a8ba68

Browse files
authored
Add AGNETS.md for coding agents (#36)
1 parent 533e9c0 commit 7a8ba68

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

AGENTS.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# AGENTS.md
2+
Guide for autonomous coding agents (e.g., OpenAI Codex) working in **streamnative-mcp-server**
3+
4+
---
5+
6+
## 1 | Project snapshot
7+
* **What it is** – A fast, developer-friendly **Model Context Protocol (MCP) server** that lets LLM agents talk to **Apache Kafka, Apache Pulsar, and StreamNative Cloud** through a single, consistent interface.
8+
* **Key outputs** – A single Go binary named **`snmcp`** (and a Docker image) that can run as a *stdio* or *SSE* server.
9+
* **Primary language / tooling** – Go 1.22+, `make`, `golangci-lint`, `goreleaser`.
10+
11+
---
12+
13+
## 2 | Repo map (orient yourself quickly)
14+
15+
| Path | What lives here | Touch with care? |
16+
|------|-----------------|------------------|
17+
| `cmd/streamnative-mcp-server/` | `main.go` entry‑point for the CLI/server | **yes** |
18+
| `pkg/` | Core library packages (Kafka tools, Pulsar tools, cloud integration, feature gating) | yes |
19+
| `sdk/` | Thin Go client helpers (generated) | can be re‑generated |
20+
| `docs/tools/` | One Markdown file per MCP tool – these are surfaced to the LLM at runtime | **yes** |
21+
| `.github/workflows/` | CI (lint, unit test, release) | only if changing CI |
22+
| `Makefile` | Local build helpers (`make build`, `make fix-license`, …) | safe |
23+
24+
---
25+
26+
## 3 | Required dev workflow
27+
28+
> **Agents MUST follow every step below before committing code or opening a PR.**
29+
30+
1. **Install deps**
31+
```bash
32+
brew install golangci-lint # or use the install script
33+
go install github.com/elastic/go-licenser@latest
34+
```
35+
36+
2. **Build & unit tests**
37+
```bash
38+
make build # invokes `go build …` with version metadata
39+
go test ./... # _there are few tests today – add more!_
40+
```
41+
42+
3. **Static analysis & formatting**
43+
Run `golangci-lint run` and ensure **zero** issues. Linters enabled include `govet`, `staticcheck`, `revive`, `gosec`, etc.
44+
Follow `go fmt` / `goimports` import grouping.
45+
46+
4. **License headers**
47+
```bash
48+
make fix-license # injects Apache 2.0 headers via go-licenser
49+
```
50+
51+
5. **Generate artifacts** (only if you edited code‑gen files)
52+
```bash
53+
go generate ./...
54+
go mod tidy
55+
```
56+
57+
6. **Commit & conventional message**
58+
Use **Conventional Commits** (`feat:`, `fix:`, `docs:` …). Keep title ≤ 72 chars and add a body explaining _why_.
59+
60+
7. **Run the full release checks locally (optional but recommended)**
61+
```bash
62+
goreleaser release --snapshot --clean # mirrors CI pipeline
63+
```
64+
65+
---
66+
67+
## 4 | How to run the server locally
68+
69+
```bash
70+
# StreamNative Cloud (stdio)
71+
bin/snmcp stdio --organization $ORG --key-file my_sa.json
72+
# External Kafka
73+
bin/snmcp stdio --use-external-kafka --kafka-bootstrap-servers localhost:9092
74+
# External Pulsar
75+
bin/snmcp stdio --use-external-pulsar --pulsar-web-service-url http://localhost:8080
76+
```
77+
78+
For HTTP/SSE mode add `sse --http-addr :9090 --http-path /mcp`.
79+
80+
---
81+
82+
## 5 | Coding conventions
83+
84+
* **Package layout** – one feature per package; avoid cyclic imports.
85+
* **Error handling** – wrap with `fmt.Errorf("context: %w", err)`; export sentinel errors where appropriate.
86+
* **Logging** – rely on `zap` (already imported) with structured fields.
87+
* **Tests** – use Go’s `testing` plus `testify/require`. When adding a tool, write at least:
88+
* happy‑path invocation
89+
* typical error path
90+
* integration stub (may be skipped with `-short`)
91+
92+
---
93+
94+
## 6 | Common tasks for agents
95+
96+
| Task | Checklist |
97+
|------|-----------|
98+
| **Add a new MCP tool** | 1) create package in `pkg/tools/...` 2) update `docs/tools/<tool>.md` 3) add to feature flag map 4) go‑vet + tests |
99+
| **Bug fix** | reproduce with unit test first → fix → ensure lint/test pass |
100+
| **Docs** | update both README **and** the per‑tool doc; regenerate table of contents |
101+
| **Release prep** | bump version tag, update changelog, run `goreleaser release --snapshot` |
102+
103+
---
104+
105+
## 7 | Programmatic checks the agent MUST run
106+
107+
```bash
108+
go vet ./...
109+
golangci-lint run
110+
go test ./...
111+
make build # binary must compile for darwin/amd64 & linux/amd64
112+
```
113+
114+
Codex **must not** finish a task until all checks pass locally. If CI fails, iterate until green.
115+
116+
---
117+
118+
## 8 | Pull‑request etiquette
119+
120+
* Open PR against `main`, no new branches needed.
121+
* Include a **Summary**, **Testing plan**, and **Docs updated** checklist.
122+
* Mention which `--features` flags were affected, so reviewers know what to smoke‑test.
123+
* If the change affects the public CLI, update `README.md` usage examples.
124+
125+
---
126+
127+
## 9 | AGENTS.md spec compliance
128+
129+
This file follows the AGENTS.md spec described in the Codex system message (scope, precedence, required programmatic checks, etc.).
130+
131+
* Its scope is the **entire repository**.
132+
* Deeper‑level AGENTS.md (not currently present) may override these instructions for their subtree.
133+
* Direct human instructions in a prompt override anything here.
134+
135+
---
136+
137+
Happy hacking! 🚀

0 commit comments

Comments
 (0)