|
1 | | -# MCP "Everything" Server - Development Guidelines |
2 | | - |
3 | | -## Build, Test & Run Commands |
4 | | - |
5 | | -- Build: `npm run build` - Compiles TypeScript to JavaScript |
6 | | -- Watch mode: `npm run watch` - Watches for changes and rebuilds automatically |
7 | | -- Run STDIO server: `npm run start:stdio` - Starts the MCP server using stdio transport |
8 | | -- Run SSE server: `npm run start:sse` - Starts the MCP server with SSE transport |
9 | | -- Run StreamableHttp server: `npm run start:stremableHttp` - Starts the MCP server with StreamableHttp transport |
10 | | -- Prepare release: `npm run prepare` - Builds the project for publishing |
11 | | - |
12 | | -## Code Style Guidelines |
13 | | - |
14 | | -- Use ES modules with `.js` extension in import paths |
15 | | -- Strictly type all functions and variables with TypeScript |
16 | | -- Follow zod schema patterns for tool input validation |
17 | | -- Prefer async/await over callbacks and Promise chains |
18 | | -- Place all imports at top of file, grouped by external then internal |
19 | | -- Use descriptive variable names that clearly indicate purpose |
20 | | -- Implement proper cleanup for timers and resources in server shutdown |
21 | | -- Handle errors with try/catch blocks and provide clear error messages |
22 | | -- Use consistent indentation (2 spaces) and trailing commas in multi-line objects |
23 | | -- Match existing code style, import order, and module layout in the respective folder. |
24 | | -- Use camelCase for variables/functions, |
25 | | -- Use PascalCase for types/classes, |
26 | | -- Use UPPER_CASE for constants |
27 | | -- Use kebab-case for file names and registered tools, prompts, and resources. |
28 | | -- Use verbs for tool names, e.g., `get-annotated-message` instead of `annotated-message` |
29 | | - |
30 | | -## Extending the Server |
31 | | - |
32 | | -The Everything Server is designed to be extended at well-defined points. |
33 | | -See [Extension Points](docs/extension.md) and [Project Structure](docs/structure.md). |
34 | | -The server factory is `src/everything/server/index.ts` and registers all features during startup as well as handling post-connection setup. |
35 | | - |
36 | | -### High-level |
37 | | - |
38 | | -- Tools live under `src/everything/tools/` and are registered via `registerTools(server)`. |
39 | | -- Resources live under `src/everything/resources/` and are registered via `registerResources(server)`. |
40 | | -- Prompts live under `src/everything/prompts/` and are registered via `registerPrompts(server)`. |
41 | | -- Subscriptions and simulated update routines are under `src/everything/resources/subscriptions.ts`. |
42 | | -- Logging helpers are under `src/everything/server/logging.ts`. |
43 | | -- Transport managers are under `src/everything/transports/`. |
44 | | - |
45 | | -### When adding a new feature |
46 | | - |
47 | | -- Follow the existing file/module pattern in its folder (naming, exports, and registration function). |
48 | | -- Export a `registerX(server)` function that registers new items with the MCP SDK in the same style as existing ones. |
49 | | -- Wire your new module into the central index (e.g., update `tools/index.ts`, `resources/index.ts`, or `prompts/index.ts`). |
50 | | -- Ensure schemas (for tools) are accurate JSON Schema and include helpful descriptions and examples. |
51 | | - `server/index.ts` and usages in `logging.ts` and `subscriptions.ts`. |
52 | | -- Keep the docs in `src/everything/docs/` up to date if you add or modify noteworthy features. |
| 1 | +# MCP Everything Server — Agent Memory |
| 2 | + |
| 3 | +_Last oriented: 2026-02-13_ |
| 4 | + |
| 5 | +## Workspace + Scope |
| 6 | + |
| 7 | +- Workspace root: `/home/ssmith/source/servers/src/everything` |
| 8 | +- This directory is the package root for this server. |
| 9 | +- Generated output is in `dist/`; **edit source `.ts` files only**. |
| 10 | + |
| 11 | +## Fast Orientation Map |
| 12 | + |
| 13 | +- CLI transport selector: `index.ts` |
| 14 | +- Server factory: `server/index.ts` |
| 15 | + - Creates `McpServer` with capabilities + instructions |
| 16 | + - Registers tools/resources/prompts |
| 17 | + - Installs subscription handlers |
| 18 | + - Registers capability-gated tools in `oninitialized` |
| 19 | + - Delays initial roots sync via `setTimeout(..., 350)` |
| 20 | +- Registries: |
| 21 | + - `tools/index.ts` → `registerTools(server)` + `registerConditionalTools(server)` |
| 22 | + - `resources/index.ts` → `registerResources(server)` + `readInstructions()` |
| 23 | + - `prompts/index.ts` → `registerPrompts(server)` |
| 24 | +- Key support files: |
| 25 | + - `resources/subscriptions.ts` (resource subscribe/unsubscribe + simulated updates) |
| 26 | + - `server/logging.ts` (simulated logging) |
| 27 | + - `server/roots.ts` (client roots sync/cache) |
| 28 | + |
| 29 | +## Build / Test / Run |
| 30 | + |
| 31 | +- Build: `npm run build` |
| 32 | +- Watch: `npm run watch` |
| 33 | +- Typecheck: `npx tsc --noEmit --pretty false` |
| 34 | +- Tests: `npm test` |
| 35 | +- STDIO: `npm run start:stdio` |
| 36 | +- SSE: `npm run start:sse` |
| 37 | +- Streamable HTTP: `npm run start:streamableHttp` |
| 38 | +- Prepare release: `npm run prepare` |
| 39 | + |
| 40 | +## Search Setup (ripgrep-first) |
| 41 | + |
| 42 | +Use rg with generated/vendor exclusions: |
| 43 | + |
| 44 | +```bash |
| 45 | +rg -n --glob '!dist/**' --glob '!node_modules/**' '<pattern>' |
| 46 | +``` |
| 47 | + |
| 48 | +Useful presets: |
| 49 | + |
| 50 | +```bash |
| 51 | +rg -n --glob '!dist/**' 'registerTools|registerResources|registerPrompts|registerConditionalTools' . |
| 52 | +rg -n --glob '!dist/**' 'createServer|oninitialized|setSubscriptionHandlers|syncRoots|cleanup' server tools resources transports |
| 53 | +rg -n --glob '!dist/**' 'z\.object|inputSchema|outputSchema|zodToJsonSchema' tools |
| 54 | +rg -n --glob '!dist/**' 'setInterval|setTimeout|clearInterval|clearTimeout|onclose|SIGINT' . |
| 55 | +``` |
| 56 | + |
| 57 | +## LSP Setup (TypeScript) |
| 58 | + |
| 59 | +- Project config: `tsconfig.json` (extends `../../tsconfig.json`). |
| 60 | +- TS SDK path: `../../node_modules/typescript/lib`. |
| 61 | +- Confirm LSP/type health: `npx tsc --noEmit --pretty false`. |
| 62 | +- High-value symbol navigation targets: |
| 63 | + - `createServer` |
| 64 | + - `registerTools` / `registerConditionalTools` |
| 65 | + - `registerResources` |
| 66 | + - `registerPrompts` |
| 67 | + |
| 68 | +## Coding Rules to Preserve |
| 69 | + |
| 70 | +- ES modules with `.js` extension in TS imports. |
| 71 | +- Strong typing for functions/variables. |
| 72 | +- Prefer `async/await` over callback chains. |
| 73 | +- Tool input validation via zod schema patterns. |
| 74 | +- Keep imports at top; external imports before internal imports. |
| 75 | +- Use descriptive names. |
| 76 | +- Handle errors with `try/catch` and clear messages. |
| 77 | +- Ensure cleanup for timers/resources during shutdown. |
| 78 | +- Formatting: 2-space indent, trailing commas in multiline objects. |
| 79 | +- Naming: |
| 80 | + - camelCase: variables/functions |
| 81 | + - PascalCase: types/classes |
| 82 | + - UPPER_CASE: constants |
| 83 | + - kebab-case: filenames + registered tools/prompts/resources |
| 84 | + - Tool names should be verbs (e.g. `get-annotated-message`) |
| 85 | + |
| 86 | +## Extension Workflow |
| 87 | + |
| 88 | +1. Add module in `tools/`, `resources/`, or `prompts/` following existing pattern. |
| 89 | +2. Export `registerX(server)` from that module. |
| 90 | +3. Wire it in the domain index file. |
| 91 | +4. Keep schemas accurate and descriptive (for tools). |
| 92 | +5. Update `docs/` for notable behavioral changes. |
| 93 | +6. If registrations change, update tests that assert counts/content. |
| 94 | + |
| 95 | +## Practical Gotchas |
| 96 | + |
| 97 | +- Conditional tools are registered **after** client initialization. |
| 98 | +- Server instructions are loaded from `docs/instructions.md`. |
| 99 | +- Session-scoped behavior exists (logging, subscription updates, session resources). |
0 commit comments