|
1 | | -# Truvera MCP Service - Copilot Instructions |
| 1 | +# Truvera MCP Servers - Copilot Instructions |
2 | 2 |
|
3 | | -This is a Model Context Protocol (MCP) server built with TypeScript/Node.js for integrating with the Truvera REST API. |
| 3 | +This is a monorepo containing multiple Model Context Protocol (MCP) servers built with TypeScript/Node.js for integrating with various APIs. |
4 | 4 |
|
5 | | -## Project Overview |
| 5 | +## Repository Structure |
6 | 6 |
|
7 | | -- **Type**: MCP Server (Model Context Protocol) |
| 7 | +- **Type**: Monorepo with multiple MCP Servers |
8 | 8 | - **Language**: TypeScript/JavaScript |
9 | 9 | - **Runtime**: Node.js 18+ |
10 | 10 | - **Deployment**: Docker & Docker Compose |
11 | | -- **Primary Purpose**: Enable Claude to make authenticated REST API calls to Truvera |
| 11 | +- **Primary Purpose**: Enable Claude to make authenticated REST API calls to various Truvera services |
12 | 12 |
|
13 | | -## Key Features |
| 13 | +## Apps Structure |
| 14 | + |
| 15 | +This repository uses an `apps/` directory to organize multiple MCP servers: |
| 16 | + |
| 17 | +- `apps/truvera-api/` - Main Truvera MCP Server for verifiable credentials and DIDs |
| 18 | + |
| 19 | +Each app is a self-contained MCP server with its own: |
| 20 | +- `package.json` - Dependencies and scripts |
| 21 | +- `tsconfig.json` - TypeScript configuration |
| 22 | +- `src/` - Source code |
| 23 | +- `tests/` - Test suites |
| 24 | +- `Dockerfile` - Container build configuration |
| 25 | +- `README.md` - App-specific documentation |
| 26 | + |
| 27 | +## Truvera MCP Server (apps/truvera-api) |
| 28 | + |
| 29 | +### Key Features |
14 | 30 |
|
15 | 31 | - Configurable API endpoint via `TRUVERA_API_ENDPOINT` environment variable |
16 | 32 | - Secure API key management via `TRUVERA_API_KEY` environment variable |
17 | | -- Built-in tool: `call_truvera_api` for making HTTP requests to Truvera API |
| 33 | +- Feature-based architecture: each API area in `src/features/<feature>/` |
| 34 | +- Built-in tools for credentials, DIDs, presentations, schemas, profiles, and verification |
18 | 35 | - Multi-stage Docker build for optimized production images |
19 | 36 | - Development and debugging support via VS Code |
20 | 37 |
|
21 | | -## Environment Variables |
| 38 | +### Environment Variables |
22 | 39 |
|
23 | 40 | - **TRUVERA_API_KEY** (required): Authentication key for Truvera API |
24 | 41 | - **TRUVERA_API_ENDPOINT** (optional): Base URL for Truvera API (defaults to `https://api.truvera.com`) |
25 | 42 |
|
26 | | -## Documentation |
| 43 | +### Documentation |
27 | 44 |
|
28 | | -- See `README.md` for comprehensive setup and usage instructions |
29 | | -- See `Dockerfile` for production container build configuration |
30 | | -- See `docker-compose.yml` for local deployment |
31 | | -- See `.vscode/mcp.json` for MCP server configuration |
| 45 | +- See `apps/truvera-api/README.md` for comprehensive setup and usage instructions |
| 46 | +- **See `apps/truvera-api/copilot-instructions.md` for detailed development guidelines** |
| 47 | +- See `apps/truvera-api/Dockerfile` for production container build configuration |
| 48 | +- See `docker-compose.yml` for multi-service deployment |
| 49 | +- See `.vscode/tasks.json` for VS Code task configuration |
32 | 50 | - See `.vscode/launch.json` for VS Code debugging setup |
33 | 51 |
|
34 | 52 | ## Development Commands |
35 | 53 |
|
| 54 | +### Root Level (All Apps) |
| 55 | + |
36 | 56 | ```bash |
| 57 | +npm install # Install dependencies for all workspaces |
| 58 | +npm run build # Build all apps |
| 59 | +npm run test # Run tests for all apps |
| 60 | +npm run typecheck # Type check all apps |
| 61 | +npm run lint # Lint all apps |
| 62 | +``` |
| 63 | + |
| 64 | +### Truvera Server Specific |
| 65 | + |
| 66 | +```bash |
| 67 | +cd apps/truvera-api |
37 | 68 | npm install # Install dependencies |
38 | 69 | npm run dev # Development mode with hot reload |
39 | 70 | npm run build # Build TypeScript to JavaScript |
40 | 71 | npm start # Run production build |
41 | 72 | npm run typecheck # Run TypeScript type checking |
42 | 73 | ``` |
43 | 74 |
|
| 75 | +Or from root: |
| 76 | + |
| 77 | +```bash |
| 78 | +npm run build:truvera |
| 79 | +npm run dev:truvera |
| 80 | +npm run test:truvera |
| 81 | +``` |
| 82 | + |
44 | 83 | ## Docker Commands |
45 | 84 |
|
46 | 85 | ```bash |
47 | | -docker build -t truvera-mcp-service:latest . # Build image |
48 | | -docker-compose up -d # Start service with Docker Compose |
| 86 | +docker-compose up -d # Start all services |
49 | 87 | docker-compose logs -f # View logs |
50 | | -docker-compose down # Stop service |
| 88 | +docker-compose down # Stop all services |
| 89 | + |
| 90 | +# Build specific service |
| 91 | +docker build -t truvera-mcp-service:latest ./apps/truvera-api |
51 | 92 | ``` |
52 | 93 |
|
53 | | -## MCP Configuration |
| 94 | +## VS Code Configuration |
54 | 95 |
|
55 | | -The MCP server is configured in `.vscode/mcp.json` to run as a stdio-based server. It can be debugged locally in VS Code using the configuration in `.vscode/launch.json`. |
| 96 | +VS Code tasks and launch configurations are set up at the workspace root level: |
| 97 | +- Tasks reference `apps/truvera-api` directory |
| 98 | +- Launch configurations use correct paths to each app's build output |
| 99 | +- Each app can be debugged independently |
| 100 | + |
| 101 | +## Adding New MCP Servers |
| 102 | + |
| 103 | +1. Create new directory: `apps/<new-server>/` |
| 104 | +2. Add package.json with appropriate dependencies |
| 105 | +3. Set up TypeScript configuration |
| 106 | +4. Create src/, tests/, and scripts/ structure |
| 107 | +5. Add Dockerfile for containerization |
| 108 | +6. Update `docker-compose.yml` to include new service |
| 109 | +7. Add build tasks to `.vscode/tasks.json` |
| 110 | +8. Add CI steps to `.github/workflows/ci.yml` |
| 111 | +9. Create README.md with server-specific documentation |
56 | 112 |
|
57 | 113 | ## Security Notes |
58 | 114 |
|
59 | 115 | - API keys should be stored securely (never commit `.env` files) |
60 | 116 | - Always use HTTPS endpoints in production |
61 | | -- Docker container runs as non-root user for security |
| 117 | +- Docker containers run as non-root user for security |
62 | 118 | - Input validation is performed on API requests |
| 119 | + |
| 120 | +## Best Practices |
| 121 | + |
| 122 | +### Testing |
| 123 | +- Write E2E tests for all API integrations (they catch real bugs!) |
| 124 | +- Always clean up resources (credentials, DIDs) in `afterAll` hooks |
| 125 | +- Use TDD: write tests first, let them reveal API requirements |
| 126 | +- Load `.env` first, then `.env.test` for test-specific overrides |
| 127 | + |
| 128 | +### API Integration |
| 129 | +- Follow W3C Verifiable Credentials format for all credentials |
| 130 | +- Always wrap credentials in `{ credential: { ... } }` for POST /credentials |
| 131 | +- Use `encodeURIComponent()` for all URL parameters |
| 132 | +- Pass full VC documents to verification, not metadata |
| 133 | + |
| 134 | +### Code Quality |
| 135 | +- Enable TypeScript strict mode |
| 136 | +- Use feature-based architecture in `src/features/<feature>/` |
| 137 | +- Share common types in `src/features/shared/` |
| 138 | +- Document with inline JSDoc comments |
| 139 | +- Follow SOLID, DRY, and KISS principles for maintainable code |
| 140 | +- Follow TDD practices |
| 141 | + |
| 142 | + |
0 commit comments