Skip to content

Commit e72ab42

Browse files
Merge pull request #2 from docknetwork/features/wallet-server
Features/wallet server
2 parents 77baa9b + f33150e commit e72ab42

157 files changed

Lines changed: 26497 additions & 3253 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
1-
.node_modules/
2-
dist/
3-
node_modules/
4-
*.log
5-
.env
6-
.env.local
7-
.DS_Store
8-
*.swp
9-
*.swo
10-
*~
1+
# Ignore node_modules everywhere
2+
**/node_modules
3+
**/dist
4+
5+
# Ignore git
6+
**/.git
7+
**/.gitignore
8+
9+
# Ignore environment files
10+
**/.env
11+
**/.env.local
12+
**/.env.*.local
13+
14+
# Ignore IDE
15+
**/.vscode
16+
**/.idea
17+
**/*.swp
18+
**/*.swo
19+
20+
# Ignore test files
21+
**/*.test.ts
22+
**/*.test.js
23+
**/tests
24+
**/__tests__
25+
26+
# Ignore docs
27+
**/README.md
28+
**/*.md
29+
!apps/truvera-api/README.md
30+
31+
# Ignore CI/CD
32+
**/.github
33+
34+
# Keep only what we need for services and shared packages
35+
!packages/mcp-shared
36+
!apps/truvera-api
37+
!apps/wallet-server

.env.example

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# Example environment variables for local development
2-
# Copy this file to .env and update with your actual values
3-
4-
# Truvera API Configuration
5-
TRUVERA_API_KEY=your-api-key-here
6-
TRUVERA_API_ENDPOINT=https://api-testnet.truvera.io
7-
8-
# Node environment
9-
NODE_ENV=development
2+
# Each MCP server has its own .env file with service-specific configuration:
3+
#
4+
# - apps/truvera-api/.env.example - Truvera REST API service
5+
# - apps/wallet-server/.env.example - Truvera Wallet SDK service
6+
#
7+
# Copy the relevant .env.example to .env in each app directory and update with your values

.env.tests

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/copilot-instructions.md

Lines changed: 99 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,142 @@
1-
# Truvera MCP Service - Copilot Instructions
1+
# Truvera MCP Servers - Copilot Instructions
22

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.
44

5-
## Project Overview
5+
## Repository Structure
66

7-
- **Type**: MCP Server (Model Context Protocol)
7+
- **Type**: Monorepo with multiple MCP Servers
88
- **Language**: TypeScript/JavaScript
99
- **Runtime**: Node.js 18+
1010
- **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
1212

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
1430

1531
- Configurable API endpoint via `TRUVERA_API_ENDPOINT` environment variable
1632
- 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
1835
- Multi-stage Docker build for optimized production images
1936
- Development and debugging support via VS Code
2037

21-
## Environment Variables
38+
### Environment Variables
2239

2340
- **TRUVERA_API_KEY** (required): Authentication key for Truvera API
2441
- **TRUVERA_API_ENDPOINT** (optional): Base URL for Truvera API (defaults to `https://api.truvera.com`)
2542

26-
## Documentation
43+
### Documentation
2744

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
3250
- See `.vscode/launch.json` for VS Code debugging setup
3351

3452
## Development Commands
3553

54+
### Root Level (All Apps)
55+
3656
```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
3768
npm install # Install dependencies
3869
npm run dev # Development mode with hot reload
3970
npm run build # Build TypeScript to JavaScript
4071
npm start # Run production build
4172
npm run typecheck # Run TypeScript type checking
4273
```
4374

75+
Or from root:
76+
77+
```bash
78+
npm run build:truvera
79+
npm run dev:truvera
80+
npm run test:truvera
81+
```
82+
4483
## Docker Commands
4584

4685
```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
4987
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
5192
```
5293

53-
## MCP Configuration
94+
## VS Code Configuration
5495

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
56112

57113
## Security Notes
58114

59115
- API keys should be stored securely (never commit `.env` files)
60116
- 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
62118
- 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+

.github/workflows/ci.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,24 @@ jobs:
2020
with:
2121
node-version: ${{ matrix.node-version }}
2222
cache: 'npm'
23+
cache-dependency-path: 'package-lock.json'
2324

24-
- name: Install dependencies
25-
run: npm ci
25+
- name: Install dependencies (monorepo)
26+
run: npm ci --workspaces
2627

27-
- name: Build (TypeScript)
28-
run: npm run build
28+
- name: Build shared package
29+
run: npm run build:shared
2930

30-
- name: Unit tests
31-
run: npm run test -- --run --testNamePattern "^unit:"
31+
- name: Build truvera-api
32+
run: npm run build:api
3233

33-
- name: Integration tests
34-
run: npm run test -- --run --testNamePattern "^integration:"
34+
- name: Build wallet-server
35+
run: npm run build --workspace=apps/wallet-server
3536

36-
- name: E2E tests
37-
run: npm run test -- --run --testNamePattern "^e2e:"
37+
- name: Run tests (truvera-api)
38+
run: npm run test -- --run
39+
working-directory: apps/truvera-api
3840

39-
- name: Smoke tests
40-
run: npm run smoke
41+
- name: Run tests (mcp-shared)
42+
run: npm run test -- --run
43+
working-directory: packages/mcp-shared
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'apps/truvera-api/**'
9+
- 'packages/mcp-shared/**'
10+
- '.github/workflows/docker-publish.yml'
11+
release:
12+
types: [published]
13+
14+
workflow_dispatch:
15+
inputs:
16+
push:
17+
description: 'Push images to DockerHub'
18+
required: false
19+
default: true
20+
type: boolean
21+
22+
jobs:
23+
build-and-push:
24+
name: Build and Push truvera-api-mcp
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: write
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Read build number
35+
id: build_number
36+
run: |
37+
BUILD_NUM=$(cat apps/truvera-api/.buildnumber)
38+
echo "build_number=$BUILD_NUM" >> $GITHUB_OUTPUT
39+
echo "Build number: $BUILD_NUM"
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v3
43+
44+
- name: Log in to DockerHub
45+
if: github.event_name != 'pull_request'
46+
uses: docker/login-action@v3
47+
with:
48+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
49+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
50+
51+
- name: Extract metadata for Docker
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: |
56+
${{ secrets.DOCKER_HUB_USERNAME }}/truvera-api-mcp
57+
tags: |
58+
type=raw,value=latest,enable={{is_default_branch}}
59+
type=raw,value=${{ steps.build_number.outputs.build_number }}
60+
type=semver,pattern={{version}}
61+
type=semver,pattern={{major}}.{{minor}}
62+
type=sha,prefix={{branch}}-
63+
64+
- name: Build and push Docker image
65+
uses: docker/build-push-action@v5
66+
with:
67+
context: .
68+
file: ./apps/truvera-api/Dockerfile
69+
push: ${{ github.event_name != 'pull_request' && (github.event.inputs.push == 'true' || github.event.inputs.push == null) }}
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}
72+
build-args: |
73+
BUILD_NUMBER=${{ steps.build_number.outputs.build_number }}
74+
cache-from: type=gha
75+
cache-to: type=gha,mode=max
76+
platforms: linux/amd64,linux/arm64
77+
78+
- name: Image digest
79+
run: echo "Image pushed with digest ${{ steps.docker_build.outputs.digest }}"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ npm-debug.log*
77
.DS_Store
88
truvera/
99
.buildnumber
10-
src/build-info.ts
10+
src/build-info.ts
11+
apps/truvera-api/.env.test

.vscode/launch.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
{
55
"type": "node",
66
"request": "launch",
7-
"name": "Debug MCP Service",
8-
"program": "${workspaceFolder}/dist/index.js",
9-
"preLaunchTask": "build",
10-
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
7+
"name": "Debug MCP Service (Truvera)",
8+
"program": "${workspaceFolder}/apps/truvera-api/dist/index.js",
9+
"preLaunchTask": "build:truvera",
10+
"outFiles": ["${workspaceFolder}/apps/truvera-api/dist/**/*.js"],
11+
"cwd": "${workspaceFolder}/apps/truvera-api",
1112
"env": {
1213
"TRUVERA_API_KEY": "${config:truvera.apiKey}",
1314
"TRUVERA_API_ENDPOINT": "${config:truvera.apiEndpoint}"

0 commit comments

Comments
 (0)