Skip to content

Commit ff042e2

Browse files
authored
feat: add all AI agents files (#40)
1 parent 4e33180 commit ff042e2

File tree

7 files changed

+245
-0
lines changed

7 files changed

+245
-0
lines changed

.claude/settings.local.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(npm lint:*)",
5+
"Bash(npm format:*)",
6+
"Bash(npm test:*)",
7+
"mcp__context7__resolve-library-id",
8+
"mcp__context7__get-library-docs",
9+
"mcp__github__get_file_contents",
10+
"mcp__github__get_issue",
11+
"Bash(grep:*)",
12+
"WebFetch(domain:github.com)",
13+
"Bash(node:*)"
14+
],
15+
"deny": []
16+
}
17+
}

.cursorrules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

AGENT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

AGENTS.md

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
# AGENTS.md: AI Collaboration Guide
2+
3+
This document provides essential guidelines for AI models interacting with this MCP (Model Context Protocol) server playground project. Adhering to these standards ensures consistency and maintains code quality.
4+
5+
## Project Overview
6+
7+
**MCP Server Playground** - A TypeScript-based Model Context Protocol server with HTTP transport, OAuth proxy for 3rd party authorization (Auth0), and stateful session management using Valkey. Provides tools for AWS services, system utilities, and streaming capabilities.
8+
9+
**Project Structure:**
10+
11+
- `/src`: Source code directory
12+
- `/core`: MCP server core implementation
13+
- `/mcpServer.ts`: Main server with capabilities and handlers
14+
- `/server/http/`: Express.js HTTP transport with middleware
15+
- `/server/auth/`: OAuth proxy with dynamic client registration
16+
- `/server/transport/`: Session management and transport handling
17+
- `/storage/`: Pluggable storage abstraction (Memory/Valkey)
18+
- `/tools`: MCP tool implementations with streaming support
19+
- `/prompts`: MCP prompt handlers and registry
20+
- `/libraries`: External service integrations (AWS SDK)
21+
- `/config`: Centralized configuration with Zod validation
22+
- `/test`: Test files and setup utilities
23+
24+
## Development Commands
25+
26+
- **Build**: `npm run build` (Rspack)
27+
- **Development**: `npm run dev` (auto-reload + pretty logging)
28+
- **Production**: `npm start`
29+
- **Type check**: `npm run typecheck`
30+
- **Lint**: `npm run lint` / `npm run lint:fix`
31+
- **Format**: `npm run format` / `npm run format:check`
32+
- **Test**: `npm test` / `npm run test:watch`
33+
- **MCP Inspector**: `npm run test:inspector`
34+
- **Docker**: `npm run docker:build` / `npm run docker:run`
35+
36+
## TypeScript & Code Style
37+
38+
- **Language**: Use TypeScript for all development with strict mode enabled
39+
- **Strictness**: Maximum TypeScript strictness (`exactOptionalPropertyTypes`, `noUncheckedIndexedAccess`, `noImplicitReturns`)
40+
- **Module System**: ESM with NodeNext resolution, path aliases (`@/``src/`)
41+
- **Import Organization**: Auto-sorted with `simple-import-sort` plugin
42+
- **Functions**: MUST include explicit return types for all functions
43+
- **Naming Conventions**: Use meaningful variable/function names; prefer "URL" (not "Url"), "API" (not "Api"), "ID" (not "Id")
44+
- **Comments**: Add JSDoc comments for complex logic and public APIs
45+
- **Complexity Limits**: Max 15 complexity, 4 depth, 120 lines/function, 5 params
46+
- **Error Handling**: No floating promises, require await, strict boolean expressions
47+
- **Type Safety**: NEVER use `@ts-expect-error` or `@ts-ignore` - fix type issues properly
48+
- **Patterns**: Prefer functional programming, `const` over `let`, template literals, async/await
49+
- **Comments policy**: Only write high-value comments if at all. Avoid talking to the user through comments.
50+
51+
## MCP Implementation Patterns
52+
53+
**Server Setup:**
54+
55+
- Initialize MCP server with proper capabilities (streaming, progress notifications)
56+
- Use `@modelcontextprotocol/sdk` for core MCP functionality
57+
- Implement HTTP transport with `StreamableHTTPServerTransport`
58+
59+
**Tool Development:**
60+
61+
```typescript
62+
// Use ToolBuilder pattern for creating tools
63+
const myTool = new ToolBuilder<MyInput, MyOutput>('tool-name')
64+
.description('Tool description')
65+
.inputSchema(MyInputSchema)
66+
.outputSchema(MyOutputSchema)
67+
.streamingImplementation(async function* (input, context) {
68+
// Implement streaming tool logic with progress notifications
69+
yield { success: true, data: result };
70+
})
71+
.build();
72+
```
73+
74+
**Tool Requirements:**
75+
76+
- All tools MUST implement `ToolBuilder` interface with streaming support
77+
- Use Zod schemas for input/output validation
78+
- Implement proper error handling with structured responses
79+
- Support progress notifications for long-running operations
80+
- Register tools in `ToolRegistry` for automatic discovery
81+
82+
**Session Management:**
83+
84+
- Stateful sessions using Valkey for clustering support
85+
- Session replay mechanism for distributed deployments
86+
- Proper transport lifecycle management
87+
88+
## Testing
89+
90+
- **Framework**: Jest with ts-jest preset, Node.js environment
91+
- **Test Files**: `*.test.ts` pattern in `src/__tests__/` or alongside source
92+
- **Coverage**: Enabled with text, lcov, clover, and json reporters
93+
- **Timeout**: 10 seconds default with auto-clear and restore mocks
94+
- **Test Writing**: Use descriptive names without "should" prefix
95+
- **Commands**:
96+
97+
```bash
98+
npm test # Run all tests
99+
npm test -- --coverage # Run with coverage
100+
npm test -- path/to/test # Run specific test
101+
npm run test:watch # Watch mode
102+
```
103+
104+
## Architecture
105+
106+
- **Runtime**: Node.js ≥22.17.0, npm ≥11.5.2
107+
- **Build System**: Rspack for fast TypeScript compilation
108+
- **Transport**: HTTP-based MCP server with Express.js and streaming support
109+
- **Authentication**: OAuth 2.0 proxy with Auth0, JWT tokens, session management
110+
- **Storage**: Pluggable storage with Memory and Valkey (Redis-compatible) implementations
111+
- **AWS Integration**: ECS, S3, Bedrock Runtime, CloudWatch Logs
112+
- **Logging**: Pino structured logging with context tracking and request correlation
113+
114+
## Security & Best Practices
115+
116+
- **Authentication**: OAuth 2.0 flow with Auth0 provider, JWT tokens with configurable TTL
117+
- **Environment Variables**: NEVER commit secrets; use `.env` files for local development
118+
- **Input Validation**: Use Zod schemas for all input validation and type safety
119+
- **Security Headers**: Helmet middleware and rate limiting enabled
120+
- **AWS Credentials**: Support multiple credential providers (profile, environment, instance metadata)
121+
- **Protocol Enforcement**: MCP protocol version validation middleware
122+
- **Error Handling**: Structured error responses with proper HTTP status codes
123+
124+
## Configuration Management
125+
126+
Centralized in `src/config/` with Zod validation:
127+
128+
- **Type Definitions**: `src/config/type.ts` - Zod schemas for all config options
129+
- **Manager**: `src/config/manager.ts` - Singleton pattern with environment overrides
130+
- **Environment Variables**: Override any config via environment variables
131+
- **Required Updates**: When adding config options, update:
132+
1. Schema definitions with Zod validation
133+
2. Default values in ConfigManager
134+
3. Environment variable documentation
135+
4. Related service configurations
136+
137+
## Quality Checks
138+
139+
Before submitting changes, run these programmatic checks:
140+
141+
```bash
142+
npm run lint # ESLint with TypeScript rules
143+
npm run typecheck # TypeScript compilation check
144+
npm run format:check # Prettier formatting check
145+
npm run test # Jest test suite
146+
npm run build # Production build verification
147+
```
148+
149+
All checks MUST pass before merging. Use `npm run lint:fix` and `npm run format` to auto-fix issues.
150+
151+
## Pull Request Guidelines
152+
153+
- **Title**: Ensure title is meaningful and clear
154+
- **Description**: Include clear description of changes and rationale
155+
- **Issues**: Reference related GitHub issues using `#issue-number`
156+
- **Tests**: Ensure all existing tests pass and add tests for new features
157+
- **Coverage**: Maintain or improve test coverage
158+
- **Screenshots**: Include screenshots for UI/output changes
159+
- **Focus**: Keep PRs focused on a single concern or feature
160+
- **MCP Compliance**: Verify MCP protocol compatibility with inspector testing
161+
162+
## Git Workflow
163+
164+
- **Pre-commit Hooks**: Husky + lint-staged for automated formatting and linting
165+
- **Commit Convention**: Use conventional commits (enforced by commitlint)
166+
- **Branch Protection**: NEVER force push to main branch
167+
- **Quality Gates**: All commits must pass linting, type checking, and tests
168+
169+
## Development Setup
170+
171+
The following steps will get your local development environment up and running.
172+
173+
### 1. Install Dependencies
174+
175+
```bash
176+
npm install
177+
```
178+
179+
### 2. Configure Environment
180+
181+
Create a `.env` file by copying the example:
182+
183+
```bash
184+
cp .env.example .env
185+
```
186+
187+
This file holds configuration for the server, authentication, and tools. Key variables include:
188+
189+
- `MCP_CONFIG_SERVER_HTTP_PORT`: The port for the MCP server (default: `3000`).
190+
- `MCP_CONFIG_STORAGE_TYPE`: The storage backend. Can be `valkey` (default, requires Docker) or `memory`.
191+
- `MCP_CONFIG_SERVER_AUTH_ENABLED`: Set to `true` to enable Auth0 authentication, or `false` to disable it for local development.
192+
- `AUTH0_*_...`: If auth is enabled, these variables must be configured with your Auth0 application details.
193+
- `MCP_CONFIG_TOOLS_AWS_*`: (Optional) AWS credentials for tools that interact with AWS services.
194+
195+
### 3. Initialize Development Environment
196+
197+
Run the one-time setup script:
198+
199+
```bash
200+
npm run dev:setup
201+
```
202+
203+
This command uses `docker-compose` to start the Valkey (Redis-compatible) database required for session and data storage.
204+
205+
### 4. Run the Development Server
206+
207+
```bash
208+
npm run dev
209+
```
210+
211+
This will start the server with auto-reloading on file changes. The server will be accessible at `http://localhost:3000`.
212+
213+
**MCP Inspector Testing**:
214+
215+
```bash
216+
cp mcp-config.example.json mcp-config.json
217+
npm run test:inspector # Test with MCP Inspector
218+
```
219+
220+
**Local Testing with Cursor**:
221+
Create `.cursor/mcp.json` with server configuration pointing to `http://localhost:3000/mcp`
222+
223+
Always run quality checks before committing. This project maintains high code quality with comprehensive TypeScript strictness and MCP protocol compliance.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

GEMINI.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

0 commit comments

Comments
 (0)