This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm run build # Compile TypeScript to dist/
npm start # Run with default transport (STDIO)
node dist/index.js # Direct execution (equivalent to npm start)
node dist/index.js --http # Run with HTTP transport on port 3000
node dist/index.js --stdio # Run with STDIO transport (explicit)
PORT=8080 node dist/index.js --http # HTTP transport on custom portnpm test # Run all tests once
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverage report
npx vitest run src/tools/ # Run specific test directory
npx vitest run --grep "HTTP" # Run tests matching patternnpm run lint # Lint code with Biome
npm run format # Format code with Biome
npm run check:format # Check formatting without modifying files
npx @biomejs/biome check --fix --unsafe # Fix import organizationnpm run docker:build # Build Docker image
npm run docker:run # Run container locally (HTTP mode)
docker compose up -d # Start with MinIO for testing
sh run-inspector.sh # Debug with MCP Inspector (auto-detects transport)
sh run-inspector.sh --docker --stdio # Debug in Docker with STDIO
sh run-inspector.sh --docker --http # Debug in Docker with HTTPThis is an AWS S3 Model Context Protocol (MCP) server with a modular architecture supporting multiple transport protocols (STDIO, HTTP, StreamableHTTP).
Application Layer (src/application.ts)
- Main Application class with dependency injection and configuration management
- Handles CLI argument parsing and environment setup
- Orchestrates transport factory creation and server initialization
Entry Point (src/index.ts)
- Minimal bootstrap that creates Application instance with parsed CLI arguments
- Supports
--stdio,--http, and transport auto-detection based on environment - Handles process exit and error scenarios gracefully
Transport Abstraction (src/transports/)
ITransportinterface provides consistent contract for all transport typesITransportFactoryenables runtime transport selection via factory patternStdioTransport: Direct process communication (default for Claude Desktop)HttpTransport: REST API + Server-Sent Events with session management- Supports both StreamableHTTP and traditional HTTP with proper MCP protocol compliance
MCP Server (src/server.ts)
- Creates McpServer instance with S3 tools registration
- Transport-agnostic server configuration
- Tool registration via factory pattern from
src/tools/index.ts
S3 Resource Layer (src/resources/s3.ts)
- Centralized AWS S3 client management and configuration
- Bucket access validation and filtering based on S3_BUCKETS environment variable
- Provides core S3 operations with error handling and type safety
Tools Layer (src/tools/)
- Individual MCP tools implementing IMCPTool interface
- Each tool (ListBuckets, ListObjects, GetObject) wraps S3Resource operations
- Consistent error handling and response formatting across all tools
HTTP Mock Utilities (src/utils/httpMock.ts)
- Bridges Hono HTTP context to Node.js IncomingMessage/ServerResponse
- Enables StreamableHTTPServerTransport compatibility with Hono framework
- Handles session management and streaming response creation
- SOLID Principles: Single responsibility, open/closed, dependency inversion throughout
- Factory Pattern: Transport and tool creation through factory functions
- Dependency Injection: Application class receives configuration, transport injection
- Transport Abstraction: Unified interface supporting STDIO, HTTP, and streaming protocols
- Session Management: HTTP transport maintains stateful MCP sessions with proper initialization
S3_BUCKETS: Comma-separated list of allowed buckets (security control)AWS_REGION: AWS region for S3 operationsS3_MAX_BUCKETS: Limits bucket listing resultsPORT: HTTP server port (default: 3000)MCP_TRANSPORT: Force specific transport type ("stdio" or "http")
MCP Session Lifecycle: HTTP transport requires proper session initialization before tool calls
- Clients must send
initializerequest beforetools/listortools/call - Sessions are identified by
sessionIdquery parameter ormcp-session-idheader - StreamableHTTPServerTransport validates Accept headers: requires both
application/jsonandtext/event-stream
- Unit Tests: Mocked AWS SDK clients with Vitest
- Integration Tests: Real HTTP server startup with session management testing
- SSE Testing: TransformStream and streaming response validation
- Docker Integration: MinIO compatibility testing via Docker Compose