5.8 KiB
5.8 KiB
Repository Guidelines
If you are unsure about sth, just google it.
Project Structure & Module Organization
src/: TypeScript source for the runtime and CLI entry points (cli.ts,runtime.ts, etc.).tests/: Vitest suites mirroring runtime behaviors; integration specs live alongside unit tests.docs/: Reference material for MCP usage and server coordination.dist/: Generated build artifacts; never edit by hand.
Build, Test, and Development Commands
pnpm build: Emits compiled JS and type declarations viatsc -p tsconfig.build.json.pnpm lint: Runs Biome style checks, Oxlint+tsgolint rules, and atsgo --noEmittype pass.pnpm test: Executes the full Vitest suite once.pnpm dev: Watches and incrementally rebuilds the library with TypeScript.pnpm clean: Removesdist/so you can verify fresh builds.pnpm run docs:list: Lists required rule summaries viascripts/docs-list.ts; run this at the start of every session and reopen any referenced doc before writing code.tmux new-session -- pnpm mcporter:list: Exercise the CLI in a resilient terminal; tmux makes it easy to spot stalls or hung servers.gh run list --limit 1 --watch: Stream CI status in real time; usegh run view --logon the returned run id to inspect failures quickly.
Guardrail Tooling (runner/git wrappers)
- Use
./runner <command>for every non-trivial shell command (tests, builds, npm, node, bun, etc.). The Bun-backed runner enforces timeouts, blocks risky subcommands, and keeps logs consistent. Only simple read-only tools (e.g.,cat,ls,rg) may bypass it. - When you must run git, invoke it through the wrapper:
./runner git status -sb,./runner git diff, or./runner git log. Those are the only git subcommands permitted. Never rungit pushunless the user asks explicitly, and even then go through./runner git push. - Never call
git add/git commitdirectly. To create a commit, list the exact paths via./scripts/committer "type: summary" path/to/file1 path/to/file2. - If you need to run the Bun-based git policy helper directly, you can use
./git ..., but prefer./runner git ...so logging stays uniform.
Coding Style & Naming Conventions
- TypeScript files use 2-space indentation, modern ES module syntax, and
strictcompiler settings. - Imports stay sorted logically; prefer relative paths within
src/. - Run
pnpm lint:biomebefore committing to auto-fix formatting;pnpm lint:oxlintenforces additional TypeScript rules powered by tsgolint. - Use descriptive function and symbol names (
createRuntime,StreamableHTTPServerTransport) and favorconstfor bindings.
Testing Guidelines
- Add unit tests under
tests/; mirror filename (runtime.test.ts) against the module under test. - Use Vitest’s
describe/it/expectAPIs; keep asynchronous testsasyncto match runtime usage. - For integration scenarios, reuse the HTTP harness shown in
tests/runtime-integration.test.tsand ensure transports close inafterAll. - Validate new work with
pnpm testand confirmpnpm lintstays green.
Changelog Guidelines
- Focus on user-facing behavior changes; avoid calling out internal testing-only updates.
- Do not mention doc-only edits; keep documentation updates out of the CHANGELOG entirely.
Commit & Pull Request Guidelines
- Use Conventional Commits (https://www.conventionalcommits.org/en/v1.0.0/) with the allowed types
feat|fix|refactor|build|ci|chore|docs|style|perf|test, optional scopes (type(scope): description), and!for breaking changes (e.g.,feat: Prevent racing of requests,chore!: Drop support for iOS 16). - Commits should be scoped and written in imperative mood (
feat: add runtime cache eviction,fix(cli): ensure list handles empty config). - Reference related issues in the body (
Refs #123) and describe observable behavior changes. - Pull requests should summarize the change set, list verification steps (
pnpm lint,pnpm test), and include screenshots or logs when CLI output changes.
Security & Configuration Tips
- Keep secrets out of the repo; pass credentials via environment variables when exercising MCP servers.
- Local scripts under
scripts/(e.g.,mcp_signoz_retry_patch.cjs) are safe shims for Sweetistics workflows—review them before extending.
Common mcporter Workflows & Shortcuts
- List configured servers:
npx mcporter list [--json]shows health, counts, and hints; re-run with--server <name>for focused detail. - Ad-hoc HTTP:
npx mcporter call https://host/path.toolName(arg: "value")automatically infers transport; add--allow-httpfor plain HTTP. - Ad-hoc stdio / third-party packages:
npx mcporter call --stdio "npx -y package@latest" --name friendly-name <tool>launches transient MCP servers (ideal for Chrome DevTools or Playwright friends with no config). - Generate standalone CLIs:
npx mcporter generate-cli <server-or-adhoc-flags> --output cli.ts [--bundle dist/cli.js --compile]embeds schema+commands; combine with--stdio/--http-urlto avoid editing configs. - Emit typed clients:
npx mcporter emit-ts <server> --mode client --out clients/name.ts [--include-optional]for TypeScript interfaces + helper factories (use--mode typesfor.d.tsonly). - Inspect/Regenerate artifacts:
npx mcporter inspect-cli dist/thing.jsprints metadata and replay command;npx mcporter generate-cli --from dist/thing.jsreruns with the latest mcporter.
Release Reminders
- Always read
RELEASE.mdbefore starting a release; follow every step (including Homebrew + docs updates) before tagging/publishing. - Global help automatically short-circuits regardless of command inference. Use
mcporter help listif you need command-specific detail. - Global help automatically short-circuits regardless of command inference. Use
mcporter help listif you need command-specific detail.