@frontmcp/skills 0.0.1 → 1.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/catalog/TEMPLATE.md +58 -13
- package/catalog/frontmcp-config/SKILL.md +140 -0
- package/catalog/frontmcp-config/references/configure-auth.md +238 -0
- package/catalog/frontmcp-config/references/configure-elicitation.md +178 -0
- package/catalog/frontmcp-config/references/configure-http.md +205 -0
- package/catalog/frontmcp-config/references/configure-session.md +205 -0
- package/catalog/frontmcp-config/references/configure-throttle.md +229 -0
- package/catalog/frontmcp-config/references/configure-transport.md +195 -0
- package/catalog/frontmcp-config/references/setup-redis.md +4 -0
- package/catalog/frontmcp-config/references/setup-sqlite.md +4 -0
- package/catalog/frontmcp-deployment/SKILL.md +124 -0
- package/catalog/frontmcp-deployment/references/build-for-browser.md +138 -0
- package/catalog/frontmcp-deployment/references/build-for-cli.md +138 -0
- package/catalog/{deployment/build-for-sdk/SKILL.md → frontmcp-deployment/references/build-for-sdk.md} +65 -24
- package/catalog/frontmcp-deployment/references/deploy-to-cloudflare.md +213 -0
- package/catalog/{deployment/deploy-to-lambda/SKILL.md → frontmcp-deployment/references/deploy-to-lambda.md} +73 -60
- package/catalog/{deployment/deploy-to-node/references/Dockerfile.example → frontmcp-deployment/references/deploy-to-node-dockerfile.md} +11 -2
- package/catalog/{deployment/deploy-to-node/SKILL.md → frontmcp-deployment/references/deploy-to-node.md} +65 -37
- package/catalog/frontmcp-deployment/references/deploy-to-vercel-config.md +60 -0
- package/catalog/frontmcp-deployment/references/deploy-to-vercel.md +224 -0
- package/catalog/frontmcp-development/SKILL.md +118 -0
- package/catalog/frontmcp-development/references/create-adapter.md +165 -0
- package/catalog/{development/create-agent/references/llm-config.md → frontmcp-development/references/create-agent-llm-config.md} +5 -5
- package/catalog/{development/create-agent/SKILL.md → frontmcp-development/references/create-agent.md} +82 -44
- package/catalog/{development/create-job/SKILL.md → frontmcp-development/references/create-job.md} +61 -19
- package/catalog/{plugins/create-plugin-hooks/SKILL.md → frontmcp-development/references/create-plugin-hooks.md} +63 -11
- package/catalog/{plugins/create-plugin/SKILL.md → frontmcp-development/references/create-plugin.md} +65 -60
- package/catalog/{development/create-prompt/SKILL.md → frontmcp-development/references/create-prompt.md} +62 -26
- package/catalog/{development/create-provider/SKILL.md → frontmcp-development/references/create-provider.md} +62 -27
- package/catalog/{development/create-resource/SKILL.md → frontmcp-development/references/create-resource.md} +62 -30
- package/catalog/{development/create-skill-with-tools/SKILL.md → frontmcp-development/references/create-skill-with-tools.md} +69 -24
- package/catalog/{development/create-skill/SKILL.md → frontmcp-development/references/create-skill.md} +71 -20
- package/catalog/{development/create-tool/SKILL.md → frontmcp-development/references/create-tool.md} +62 -26
- package/catalog/{development/create-workflow/SKILL.md → frontmcp-development/references/create-workflow.md} +60 -18
- package/catalog/{development/decorators-guide/SKILL.md → frontmcp-development/references/decorators-guide.md} +123 -34
- package/catalog/frontmcp-development/references/official-adapters.md +194 -0
- package/catalog/{plugins/official-plugins/SKILL.md → frontmcp-development/references/official-plugins.md} +68 -22
- package/catalog/frontmcp-guides/SKILL.md +417 -0
- package/catalog/frontmcp-guides/references/example-knowledge-base.md +636 -0
- package/catalog/frontmcp-guides/references/example-task-manager.md +512 -0
- package/catalog/frontmcp-guides/references/example-weather-api.md +292 -0
- package/catalog/frontmcp-setup/SKILL.md +127 -0
- package/catalog/frontmcp-setup/references/frontmcp-skills-usage.md +265 -0
- package/catalog/{setup/multi-app-composition/SKILL.md → frontmcp-setup/references/multi-app-composition.md} +65 -23
- package/catalog/{setup/nx-workflow/SKILL.md → frontmcp-setup/references/nx-workflow.md} +78 -21
- package/catalog/frontmcp-setup/references/project-structure-nx.md +246 -0
- package/catalog/frontmcp-setup/references/project-structure-standalone.md +212 -0
- package/catalog/{setup/setup-project/SKILL.md → frontmcp-setup/references/setup-project.md} +62 -62
- package/catalog/{setup/setup-redis/SKILL.md → frontmcp-setup/references/setup-redis.md} +59 -86
- package/catalog/{setup/setup-sqlite/SKILL.md → frontmcp-setup/references/setup-sqlite.md} +64 -76
- package/catalog/frontmcp-testing/SKILL.md +121 -0
- package/catalog/{testing/setup-testing/SKILL.md → frontmcp-testing/references/setup-testing.md} +78 -67
- package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-tool-unit.md +1 -0
- package/catalog/skills-manifest.json +34 -383
- package/package.json +1 -1
- package/src/manifest.d.ts +3 -3
- package/src/manifest.js +1 -3
- package/src/manifest.js.map +1 -1
- package/catalog/adapters/create-adapter/SKILL.md +0 -127
- package/catalog/adapters/official-adapters/SKILL.md +0 -136
- package/catalog/auth/configure-auth/SKILL.md +0 -250
- package/catalog/auth/configure-session/SKILL.md +0 -201
- package/catalog/config/configure-elicitation/SKILL.md +0 -136
- package/catalog/config/configure-http/SKILL.md +0 -167
- package/catalog/config/configure-throttle/SKILL.md +0 -189
- package/catalog/config/configure-transport/SKILL.md +0 -151
- package/catalog/deployment/build-for-browser/SKILL.md +0 -95
- package/catalog/deployment/build-for-cli/SKILL.md +0 -100
- package/catalog/deployment/deploy-to-cloudflare/SKILL.md +0 -192
- package/catalog/deployment/deploy-to-vercel/SKILL.md +0 -196
- package/catalog/deployment/deploy-to-vercel/references/vercel.json.example +0 -60
- package/catalog/setup/frontmcp-skills-usage/SKILL.md +0 -200
- package/catalog/setup/project-structure-nx/SKILL.md +0 -186
- package/catalog/setup/project-structure-standalone/SKILL.md +0 -153
- /package/catalog/{auth/configure-auth/references/auth-modes.md → frontmcp-config/references/configure-auth-modes.md} +0 -0
- /package/catalog/{config/configure-throttle/references/guard-config.md → frontmcp-config/references/configure-throttle-guard-config.md} +0 -0
- /package/catalog/{config/configure-transport/references/protocol-presets.md → frontmcp-config/references/configure-transport-protocol-presets.md} +0 -0
- /package/catalog/{development/create-tool/references/tool-annotations.md → frontmcp-development/references/create-tool-annotations.md} +0 -0
- /package/catalog/{development/create-tool/references/output-schema-types.md → frontmcp-development/references/create-tool-output-schema-types.md} +0 -0
- /package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-auth.md +0 -0
- /package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-browser-build.md +0 -0
- /package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-cli-binary.md +0 -0
- /package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-direct-client.md +0 -0
- /package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-e2e-handler.md +0 -0
|
@@ -1,66 +1,26 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: setup-sqlite
|
|
3
|
-
description: Configure SQLite for local development and single-instance deployments. Use when setting up local storage, CLI tools, unix-socket daemons, or WAL mode.
|
|
4
|
-
category: setup
|
|
5
|
-
tags: [setup, sqlite, storage, local]
|
|
6
|
-
targets: [node]
|
|
7
|
-
bundle: [minimal, full]
|
|
8
|
-
hasResources: false
|
|
9
|
-
storageDefault:
|
|
10
|
-
node: sqlite
|
|
11
|
-
allowed-tools: Bash Write Edit Read Grep
|
|
12
|
-
parameters:
|
|
13
|
-
- name: walMode
|
|
14
|
-
type: boolean
|
|
15
|
-
description: Enable WAL (Write-Ahead Logging) mode for better read concurrency
|
|
16
|
-
default: true
|
|
17
|
-
- name: dbPath
|
|
18
|
-
type: string
|
|
19
|
-
description: File path for the SQLite database
|
|
20
|
-
default: '~/.frontmcp/data/sessions.sqlite'
|
|
21
|
-
- name: encryption
|
|
22
|
-
type: boolean
|
|
23
|
-
description: Enable AES-256-GCM at-rest encryption for stored values
|
|
24
|
-
default: false
|
|
25
|
-
examples:
|
|
26
|
-
- scenario: Set up SQLite storage for a CLI tool
|
|
27
|
-
parameters:
|
|
28
|
-
walMode: true
|
|
29
|
-
dbPath: '~/.frontmcp/data/sessions.sqlite'
|
|
30
|
-
encryption: false
|
|
31
|
-
- scenario: Configure SQLite for a unix-socket daemon with encryption
|
|
32
|
-
parameters:
|
|
33
|
-
walMode: true
|
|
34
|
-
dbPath: '/var/lib/frontmcp/daemon.sqlite'
|
|
35
|
-
encryption: true
|
|
36
|
-
compatibility: 'Node.js 18+. Requires better-sqlite3 native bindings (build tools needed). Linux, macOS, Windows (x64/arm64). Not recommended for multi-instance, serverless, or horizontally scaled deployments.'
|
|
37
|
-
install:
|
|
38
|
-
destinations: [project-local]
|
|
39
|
-
mergeStrategy: overwrite
|
|
40
|
-
dependencies: [setup-project]
|
|
41
|
-
metadata:
|
|
42
|
-
docs: https://docs.agentfront.dev/frontmcp/deployment/sqlite-setup
|
|
43
|
-
---
|
|
44
|
-
|
|
45
1
|
# Configure SQLite for Local and Single-Instance Deployments
|
|
46
2
|
|
|
47
|
-
## When to
|
|
3
|
+
## When to Use This Skill
|
|
4
|
+
|
|
5
|
+
### Must Use
|
|
6
|
+
|
|
7
|
+
- Your FrontMCP server runs as a single instance with local persistent storage (CLI tools, unix-socket daemons)
|
|
8
|
+
- You need session or key-value storage for local development without running external services
|
|
9
|
+
- Your deployment target is a single-process Node.js server on a machine with a local filesystem
|
|
48
10
|
|
|
49
|
-
|
|
11
|
+
### Recommended
|
|
50
12
|
|
|
51
|
-
- CLI
|
|
52
|
-
- Single-instance daemons communicating over stdio or unix socket
|
|
13
|
+
- You are building a CLI tool or local-only MCP server that will never be horizontally scaled
|
|
53
14
|
- Local development when running a Redis container is unnecessary overhead
|
|
54
|
-
- Projects that
|
|
15
|
+
- Projects that store session data, credentials, or counters on a single host
|
|
55
16
|
|
|
56
|
-
|
|
17
|
+
### Skip When
|
|
57
18
|
|
|
58
|
-
- Deploying to serverless (Vercel, Lambda, Cloudflare)
|
|
59
|
-
- Running multiple server instances
|
|
60
|
-
- You need pub/sub for resource subscriptions
|
|
61
|
-
- Horizontal scaling is required now or in the near future
|
|
19
|
+
- Deploying to serverless (Vercel, Lambda, Cloudflare) where there is no persistent local filesystem -- use `setup-redis` instead
|
|
20
|
+
- Running multiple server instances behind a load balancer -- use `setup-redis` instead
|
|
21
|
+
- You need pub/sub for resource subscriptions or real-time event distribution -- use `setup-redis` instead
|
|
62
22
|
|
|
63
|
-
|
|
23
|
+
> **Decision:** Use SQLite for single-instance local storage; switch to `setup-redis` for multi-instance or serverless deployments.
|
|
64
24
|
|
|
65
25
|
## Step 1 -- Install the Native Dependency
|
|
66
26
|
|
|
@@ -175,7 +135,7 @@ The encryption uses HKDF-SHA256 for key derivation and AES-256-GCM for value enc
|
|
|
175
135
|
walMode: true,
|
|
176
136
|
},
|
|
177
137
|
transport: {
|
|
178
|
-
protocol: '
|
|
138
|
+
protocol: 'modern', // 'modern' preset enables streamable HTTP + strict sessions
|
|
179
139
|
},
|
|
180
140
|
http: {
|
|
181
141
|
unixSocket: '/tmp/frontmcp.sock',
|
|
@@ -206,7 +166,7 @@ WAL (Write-Ahead Logging) mode is enabled by default (`walMode: true`) and is st
|
|
|
206
166
|
|
|
207
167
|
WAL mode creates two additional files alongside the database:
|
|
208
168
|
|
|
209
|
-
```
|
|
169
|
+
```text
|
|
210
170
|
sessions.sqlite # main database
|
|
211
171
|
sessions.sqlite-wal # write-ahead log
|
|
212
172
|
sessions.sqlite-shm # shared memory index
|
|
@@ -275,7 +235,7 @@ frontmcp dev
|
|
|
275
235
|
|
|
276
236
|
Check the logs for SQLite initialization:
|
|
277
237
|
|
|
278
|
-
```
|
|
238
|
+
```text
|
|
279
239
|
[SessionStoreFactory] Creating SQLite session store
|
|
280
240
|
```
|
|
281
241
|
|
|
@@ -334,26 +294,54 @@ The change in `src/main.ts`:
|
|
|
334
294
|
})
|
|
335
295
|
```
|
|
336
296
|
|
|
337
|
-
##
|
|
297
|
+
## Common Patterns
|
|
338
298
|
|
|
339
|
-
|
|
|
340
|
-
|
|
|
341
|
-
| `
|
|
342
|
-
|
|
|
343
|
-
| `
|
|
344
|
-
| `
|
|
345
|
-
|
|
|
346
|
-
| Encrypted data unreadable | Wrong or missing encryption secret | The secret must be identical across restarts; if lost, delete the database |
|
|
299
|
+
| Pattern | Correct | Incorrect | Why |
|
|
300
|
+
| ------------------------------ | -------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
|
|
301
|
+
| Database path | `path: '~/.frontmcp/data/sessions.sqlite'` | `path: './sessions.sqlite'` | Tilde-prefixed or absolute paths are stable across working directories; relative paths break when CWD changes |
|
|
302
|
+
| Encryption secret source | `secret: process.env['SQLITE_ENCRYPTION_SECRET']!` | `secret: 'hardcoded-secret-value'` | Secrets must come from environment variables, never committed to source code |
|
|
303
|
+
| WAL mode default | `walMode: true` (or omit, defaults to `true`) | `walMode: false` without a specific reason | WAL provides better read concurrency with no downside on local filesystems |
|
|
304
|
+
| Native dependency installation | `yarn add @frontmcp/storage-sqlite better-sqlite3` | `yarn add better-sqlite3` alone | Both packages are required; the storage package wraps the native bindings with FrontMCP session store logic |
|
|
305
|
+
| TTL cleanup interval | `ttlCleanupIntervalMs: 60000` (default) | `ttlCleanupIntervalMs: 500` | Overly aggressive cleanup wastes CPU; the default 60s is appropriate for most workloads |
|
|
347
306
|
|
|
348
307
|
## Verification Checklist
|
|
349
308
|
|
|
350
|
-
|
|
309
|
+
### Dependencies
|
|
310
|
+
|
|
311
|
+
- [ ] `@frontmcp/storage-sqlite` and `better-sqlite3` are in `dependencies`
|
|
312
|
+
- [ ] `@types/better-sqlite3` is in `devDependencies`
|
|
313
|
+
- [ ] `node -e "require('better-sqlite3')"` runs without errors
|
|
314
|
+
|
|
315
|
+
### Configuration
|
|
316
|
+
|
|
317
|
+
- [ ] The `sqlite` block is present in the `@FrontMcp` decorator config with a valid `path` string
|
|
318
|
+
- [ ] The database path parent directory exists and is writable
|
|
319
|
+
- [ ] WAL mode is enabled (default) unless there is a specific filesystem limitation
|
|
320
|
+
|
|
321
|
+
### Environment and Security
|
|
322
|
+
|
|
323
|
+
- [ ] Environment variables are in `.env` and `.env` is gitignored
|
|
324
|
+
- [ ] If encryption is enabled: `SQLITE_ENCRYPTION_SECRET` is set and is at least 32 characters
|
|
325
|
+
- [ ] No secrets are hardcoded in source files
|
|
326
|
+
|
|
327
|
+
### Runtime
|
|
328
|
+
|
|
329
|
+
- [ ] The server starts without SQLite errors (`frontmcp dev`)
|
|
330
|
+
- [ ] The database file is created at the configured path
|
|
331
|
+
- [ ] If WAL mode is enabled: `.sqlite-wal` and `.sqlite-shm` files appear alongside the database
|
|
332
|
+
|
|
333
|
+
## Troubleshooting
|
|
334
|
+
|
|
335
|
+
| Problem | Cause | Solution |
|
|
336
|
+
| --------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
337
|
+
| `Cannot find module 'better-sqlite3'` | Native module not installed | Run `yarn add @frontmcp/storage-sqlite better-sqlite3` |
|
|
338
|
+
| `Could not locate the bindings file` | Native compilation failed | Ensure build tools are installed (Xcode CLI on macOS, `build-essential` on Linux), delete `node_modules` and reinstall |
|
|
339
|
+
| `SQLITE_BUSY` errors | Multiple processes accessing the same database file | Enable WAL mode (`walMode: true`) or ensure only one process writes to the database |
|
|
340
|
+
| `SQLITE_READONLY` | Insufficient file permissions | Check write permissions on the database file and its parent directory |
|
|
341
|
+
| WAL errors on network mount | WAL mode requires a local filesystem with shared-memory support | Move the database to a local disk or set `walMode: false` |
|
|
342
|
+
| Encrypted data unreadable after restart | Encryption secret changed or missing | The secret must be identical across restarts; if the original secret is lost, delete the database and let it be recreated |
|
|
343
|
+
|
|
344
|
+
## Reference
|
|
351
345
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
3. `node -e "require('better-sqlite3')"` runs without errors
|
|
355
|
-
4. The `sqlite` block is present in the `@FrontMcp` decorator config with a valid `path` string
|
|
356
|
-
5. The database path parent directory exists and is writable
|
|
357
|
-
6. Environment variables are in `.env` and `.env` is gitignored
|
|
358
|
-
7. The server starts without SQLite errors (`frontmcp dev`)
|
|
359
|
-
8. If encryption is enabled: `SQLITE_ENCRYPTION_SECRET` is set and is at least 32 characters
|
|
346
|
+
- **Docs:** [SQLite Setup Guide](https://docs.agentfront.dev/frontmcp/deployment/sqlite-setup)
|
|
347
|
+
- **Related skills:** `setup-redis`, `setup-project`, `nx-workflow`
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontmcp-testing
|
|
3
|
+
description: "Domain router for testing MCP servers \u2014 unit tests, E2E tests, coverage, and quality assurance. Use when starting any testing task for a FrontMCP application."
|
|
4
|
+
tags: [router, testing, jest, e2e, coverage, quality, guide]
|
|
5
|
+
priority: 10
|
|
6
|
+
visibility: both
|
|
7
|
+
license: Apache-2.0
|
|
8
|
+
metadata:
|
|
9
|
+
docs: https://docs.agentfront.dev/frontmcp/testing/overview
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# FrontMCP Testing Router
|
|
13
|
+
|
|
14
|
+
Entry point for testing FrontMCP applications. This skill helps you navigate testing strategies across component types and find the right patterns for unit, integration, and E2E tests.
|
|
15
|
+
|
|
16
|
+
## When to Use This Skill
|
|
17
|
+
|
|
18
|
+
### Must Use
|
|
19
|
+
|
|
20
|
+
- Setting up testing infrastructure for a new FrontMCP project
|
|
21
|
+
- Deciding how to test a specific component type (tool, resource, prompt, agent)
|
|
22
|
+
- Planning a testing strategy that covers unit, E2E, and coverage requirements
|
|
23
|
+
|
|
24
|
+
### Recommended
|
|
25
|
+
|
|
26
|
+
- Looking up testing patterns for a component type you haven't tested before
|
|
27
|
+
- Understanding the relationship between unit tests, E2E tests, and coverage thresholds
|
|
28
|
+
- Troubleshooting test failures or coverage gaps
|
|
29
|
+
|
|
30
|
+
### Skip When
|
|
31
|
+
|
|
32
|
+
- You need detailed Jest configuration and test harness setup (go directly to `setup-testing`)
|
|
33
|
+
- You need to build components, not test them (see `frontmcp-development`)
|
|
34
|
+
- You need to deploy, not test (see `frontmcp-deployment`)
|
|
35
|
+
|
|
36
|
+
> **Decision:** Use this skill for testing strategy and routing. Use `setup-testing` for hands-on Jest configuration and test writing.
|
|
37
|
+
|
|
38
|
+
## Scenario Routing Table
|
|
39
|
+
|
|
40
|
+
| Scenario | Skill / Section | Description |
|
|
41
|
+
| --------------------------------------- | ---------------------------------- | --------------------------------------------------------- |
|
|
42
|
+
| Set up Jest, coverage, and test harness | `setup-testing` | Full Jest config, test utilities, and coverage thresholds |
|
|
43
|
+
| Write unit tests for a tool | `setup-testing` (Unit Testing) | Mock DI, validate input/output, test error paths |
|
|
44
|
+
| Write unit tests for a resource | `setup-testing` (Unit Testing) | Test URI resolution, template params, read results |
|
|
45
|
+
| Write unit tests for a prompt | `setup-testing` (Unit Testing) | Test argument handling, message generation |
|
|
46
|
+
| Write E2E protocol-level tests | `setup-testing` (E2E Testing) | Real MCP client/server, full protocol flow |
|
|
47
|
+
| Test authenticated endpoints | `setup-testing` + `configure-auth` | E2E with OAuth tokens, session validation |
|
|
48
|
+
| Test deployment builds | `setup-testing` + `deploy-to-*` | Smoke tests against built output |
|
|
49
|
+
|
|
50
|
+
## Testing Strategy by Component Type
|
|
51
|
+
|
|
52
|
+
| Component | Unit Test Focus | E2E Test Focus | Key Assertions |
|
|
53
|
+
| --------- | -------------------------------------------------------- | ---------------------------------- | ---------------------------------------------- |
|
|
54
|
+
| Tool | Input validation, execute logic, error paths, DI mocking | `tools/call` via MCP client | Output matches schema, errors return MCP codes |
|
|
55
|
+
| Resource | URI resolution, read content, template param handling | `resources/read` via MCP client | Content type correct, URI patterns resolve |
|
|
56
|
+
| Prompt | Argument validation, message generation, multi-turn | `prompts/get` via MCP client | Messages match expected structure |
|
|
57
|
+
| Agent | LLM config, tool selection, handoff logic | Agent loop via MCP client | Tools called in order, result synthesized |
|
|
58
|
+
| Provider | Lifecycle hooks, factory output, singleton behavior | Indirectly via tool/resource tests | Instance reuse, cleanup on scope disposal |
|
|
59
|
+
| Job | Progress tracking, retry logic, attempt counting | Job execution via test harness | Progress events emitted, retries respected |
|
|
60
|
+
|
|
61
|
+
## Cross-Cutting Testing Patterns
|
|
62
|
+
|
|
63
|
+
| Pattern | Rule |
|
|
64
|
+
| ------------------ | ------------------------------------------------------------------------------------- |
|
|
65
|
+
| File naming | Always `.spec.ts` (not `.test.ts`); E2E uses `.e2e.spec.ts` |
|
|
66
|
+
| Coverage threshold | 95%+ across statements, branches, functions, lines |
|
|
67
|
+
| Test descriptions | Plain English, no prefixes like "PT-001"; describe behavior not implementation |
|
|
68
|
+
| Mocking | Mock providers via DI token replacement, never mock the framework |
|
|
69
|
+
| Error testing | Assert `instanceof` specific error class AND MCP error code |
|
|
70
|
+
| Async | Always `await` async operations; use `expect(...).rejects.toThrow()` for async errors |
|
|
71
|
+
|
|
72
|
+
## Common Patterns
|
|
73
|
+
|
|
74
|
+
| Pattern | Correct | Incorrect | Why |
|
|
75
|
+
| ------------------ | ------------------------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------------- |
|
|
76
|
+
| Test file location | `fetch-weather.tool.spec.ts` next to source | `__tests__/fetch-weather.test.ts` | Co-location with `.spec.ts` extension matches FrontMCP conventions |
|
|
77
|
+
| DI mocking | Replace token with mock via `scope.register(TOKEN, mockImpl)` | `jest.mock('../provider')` module mock | DI mocking is cleaner, type-safe, and tests the real integration path |
|
|
78
|
+
| Error assertions | `expect(err).toBeInstanceOf(ResourceNotFoundError)` | `expect(err.message).toContain('not found')` | Class checks are stable; message strings are fragile |
|
|
79
|
+
| E2E transport | Use `@frontmcp/testing` MCP client with real server | HTTP requests with `fetch` | The test client handles protocol details (session, framing) |
|
|
80
|
+
| Coverage gaps | Investigate uncovered branches, add targeted tests | Add `istanbul ignore` comments | Coverage gaps often hide real bugs; ignoring them defeats the purpose |
|
|
81
|
+
|
|
82
|
+
## Verification Checklist
|
|
83
|
+
|
|
84
|
+
### Infrastructure
|
|
85
|
+
|
|
86
|
+
- [ ] Jest configured with `@frontmcp/testing` preset
|
|
87
|
+
- [ ] Coverage thresholds set to 95% in jest.config
|
|
88
|
+
- [ ] Test files use `.spec.ts` extension throughout
|
|
89
|
+
|
|
90
|
+
### Unit Tests
|
|
91
|
+
|
|
92
|
+
- [ ] Each tool has unit tests covering happy path, validation errors, and DI failures
|
|
93
|
+
- [ ] Each resource has unit tests covering URI resolution and read content
|
|
94
|
+
- [ ] Provider lifecycle (init, dispose) tested where applicable
|
|
95
|
+
|
|
96
|
+
### E2E Tests
|
|
97
|
+
|
|
98
|
+
- [ ] At least one E2E test exercises full MCP protocol flow (connect, list, call, disconnect)
|
|
99
|
+
- [ ] Authenticated E2E tests use proper test tokens (not mocked auth)
|
|
100
|
+
- [ ] E2E tests clean up state after execution
|
|
101
|
+
|
|
102
|
+
### CI Integration
|
|
103
|
+
|
|
104
|
+
- [ ] Tests run in CI pipeline on every PR
|
|
105
|
+
- [ ] Coverage report published and enforced
|
|
106
|
+
- [ ] Failing tests block merge
|
|
107
|
+
|
|
108
|
+
## Troubleshooting
|
|
109
|
+
|
|
110
|
+
| Problem | Cause | Solution |
|
|
111
|
+
| ---------------------------------- | ------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
112
|
+
| Jest not finding test files | Wrong file extension (`.test.ts` instead of `.spec.ts`) | Rename to `.spec.ts`; check `testMatch` in jest.config |
|
|
113
|
+
| Coverage below 95% | Untested error paths or conditional branches | Run `jest --coverage` and inspect uncovered lines in the report |
|
|
114
|
+
| E2E test timeout | Server startup too slow or port conflict | Increase Jest timeout; use random port allocation |
|
|
115
|
+
| DI resolution fails in tests | Provider not registered in test scope | Register mock providers before creating the test context |
|
|
116
|
+
| Istanbul shows 0% on async methods | TypeScript source-map mismatch with Istanbul | Known issue with some TS compilation settings; verify coverage with actual test output |
|
|
117
|
+
|
|
118
|
+
## Reference
|
|
119
|
+
|
|
120
|
+
- [Testing Documentation](https://docs.agentfront.dev/frontmcp/testing/overview)
|
|
121
|
+
- Related skills: `setup-testing`, `create-tool`, `create-resource`, `create-prompt`, `configure-auth`
|
package/catalog/{testing/setup-testing/SKILL.md → frontmcp-testing/references/setup-testing.md}
RENAMED
|
@@ -1,53 +1,29 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: setup-testing
|
|
3
|
-
description: Configure and run unit and E2E tests for FrontMCP applications. Use when writing tests, setting up Jest, configuring coverage, or testing tools and resources.
|
|
4
|
-
tags:
|
|
5
|
-
- testing
|
|
6
|
-
- jest
|
|
7
|
-
- e2e
|
|
8
|
-
- quality
|
|
9
|
-
bundle:
|
|
10
|
-
- recommended
|
|
11
|
-
- full
|
|
12
|
-
visibility: both
|
|
13
|
-
priority: 5
|
|
14
|
-
parameters:
|
|
15
|
-
- name: test-type
|
|
16
|
-
description: Type of test to set up (unit, e2e, or both)
|
|
17
|
-
type: string
|
|
18
|
-
required: false
|
|
19
|
-
default: both
|
|
20
|
-
- name: coverage-threshold
|
|
21
|
-
description: Minimum coverage percentage required
|
|
22
|
-
type: number
|
|
23
|
-
required: false
|
|
24
|
-
default: 95
|
|
25
|
-
examples:
|
|
26
|
-
- scenario: Set up unit tests for a tool with Jest
|
|
27
|
-
parameters:
|
|
28
|
-
test-type: unit
|
|
29
|
-
expected-outcome: Tool execute method is tested with mocked context, assertions verify output schema
|
|
30
|
-
- scenario: Set up E2E tests against a running MCP server
|
|
31
|
-
parameters:
|
|
32
|
-
test-type: e2e
|
|
33
|
-
expected-outcome: McpTestClient connects to server, calls tools, and verifies responses with MCP matchers
|
|
34
|
-
- scenario: Configure full test suite with 95% coverage enforcement
|
|
35
|
-
parameters:
|
|
36
|
-
test-type: both
|
|
37
|
-
coverage-threshold: 95
|
|
38
|
-
expected-outcome: Jest runs unit and E2E tests with coverage thresholds enforced in CI
|
|
39
|
-
license: MIT
|
|
40
|
-
compatibility: Requires Node.js 18+, Jest 29+, and @frontmcp/testing for E2E tests
|
|
41
|
-
metadata:
|
|
42
|
-
category: testing
|
|
43
|
-
difficulty: beginner
|
|
44
|
-
docs: https://docs.agentfront.dev/frontmcp/testing/overview
|
|
45
|
-
---
|
|
46
|
-
|
|
47
1
|
# Set Up Testing for FrontMCP Applications
|
|
48
2
|
|
|
49
3
|
This skill covers testing FrontMCP applications at three levels: unit tests for individual tools/resources/prompts, E2E tests exercising the full MCP protocol, and manual testing with `frontmcp dev`.
|
|
50
4
|
|
|
5
|
+
## When to Use This Skill
|
|
6
|
+
|
|
7
|
+
### Must Use
|
|
8
|
+
|
|
9
|
+
- Writing the first unit test for a new tool, resource, or prompt class
|
|
10
|
+
- Setting up Jest configuration and coverage thresholds for a FrontMCP library
|
|
11
|
+
- Creating E2E tests that exercise the full MCP protocol via `McpTestClient`
|
|
12
|
+
|
|
13
|
+
### Recommended
|
|
14
|
+
|
|
15
|
+
- Adding coverage enforcement to CI for an existing library that lacks thresholds
|
|
16
|
+
- Writing authenticated E2E tests with `TestTokenFactory` and `MockOAuthServer`
|
|
17
|
+
- Migrating existing `.test.ts` files to the required `.spec.ts` naming convention
|
|
18
|
+
|
|
19
|
+
### Skip When
|
|
20
|
+
|
|
21
|
+
- Building a new tool class from scratch (see `create-tool`)
|
|
22
|
+
- Creating resources or prompts before you have anything to test (see `create-resource`, `create-prompt`)
|
|
23
|
+
- Debugging deployment issues unrelated to test configuration (see `deploy-to-node`, `deploy-to-vercel`)
|
|
24
|
+
|
|
25
|
+
> **Decision:** Use this skill when you need to configure, write, or run Jest tests for FrontMCP tools, resources, or prompts.
|
|
26
|
+
|
|
51
27
|
## Testing Standards
|
|
52
28
|
|
|
53
29
|
FrontMCP requires:
|
|
@@ -65,7 +41,7 @@ FrontMCP requires:
|
|
|
65
41
|
|
|
66
42
|
Place test files next to the source file or in a `__tests__` directory:
|
|
67
43
|
|
|
68
|
-
```
|
|
44
|
+
```text
|
|
69
45
|
src/
|
|
70
46
|
tools/
|
|
71
47
|
my-tool.ts
|
|
@@ -350,7 +326,7 @@ describe('Advanced E2E', () => {
|
|
|
350
326
|
});
|
|
351
327
|
|
|
352
328
|
client = await McpTestClient.create({ baseUrl: server.info.baseUrl })
|
|
353
|
-
.withTransport('
|
|
329
|
+
.withTransport('modern') // 'modern' preset enables streamable HTTP + strict sessions
|
|
354
330
|
.buildAndConnect();
|
|
355
331
|
});
|
|
356
332
|
|
|
@@ -514,26 +490,61 @@ node scripts/fix-unused-imports.mjs feature/my-branch
|
|
|
514
490
|
| Playwright browser tests | UI tests with Playwright | `.pw.spec.ts` |
|
|
515
491
|
| Constructor validation | Unit test verifying throws on invalid input | `.spec.ts` |
|
|
516
492
|
|
|
517
|
-
## Common
|
|
493
|
+
## Common Patterns
|
|
494
|
+
|
|
495
|
+
| Pattern | Correct | Incorrect | Why |
|
|
496
|
+
| ---------------- | -------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------ |
|
|
497
|
+
| Test file naming | `my-tool.spec.ts`, `my-tool.e2e.spec.ts` | `my-tool.test.ts`, `my-tool.test.tsx` | Nx and Jest configs only recognize `.spec.ts` convention |
|
|
498
|
+
| Test description | `'should return formatted output for valid input'` | `'PT-001: test formatted output'` | Descriptive names; no ID prefixes |
|
|
499
|
+
| Mock types | `const ctx = { scope: { get: jest.fn() } } as unknown` | `const ctx: any = { scope: { get: jest.fn() } }` | Strict TypeScript; avoid `any` in mocks |
|
|
500
|
+
| Error assertion | `expect(err).toBeInstanceOf(ResourceNotFoundError)` | `expect(() => ...).toThrow()` | Verify the exact error class and MCP error code, not just that something threw |
|
|
501
|
+
| Constructor test | Always test `new MyService({})` throws on invalid config | Skip constructor validation | Catches misconfiguration early; required for 95% branch coverage |
|
|
502
|
+
| E2E test imports | `import { test, expect } from '@frontmcp/testing'` | `import { expect } from '@jest/globals'` | `@frontmcp/testing` provides MCP-specific matchers like `toContainTool()` |
|
|
503
|
+
| Coverage check | `nx test my-lib --coverage` before push | Push without coverage check | CI enforces 95% thresholds; catch failures locally first |
|
|
504
|
+
|
|
505
|
+
## Verification Checklist
|
|
506
|
+
|
|
507
|
+
### Configuration
|
|
508
|
+
|
|
509
|
+
- [ ] Jest config exists with `coverageThreshold` set to 95% for all metrics
|
|
510
|
+
- [ ] `tsconfig.spec.json` exists and extends the base tsconfig
|
|
511
|
+
- [ ] `@frontmcp/testing` is installed as a dev dependency for E2E tests
|
|
512
|
+
- [ ] Test files use `.spec.ts` (unit), `.e2e.spec.ts` (E2E), or `.perf.spec.ts` (perf) extension
|
|
513
|
+
|
|
514
|
+
### Unit Tests
|
|
515
|
+
|
|
516
|
+
- [ ] Each tool's `execute()` method is tested with valid and invalid inputs
|
|
517
|
+
- [ ] Each resource's `read()` method is tested and output matches `ReadResourceResult` shape
|
|
518
|
+
- [ ] Each prompt's `execute()` method is tested and output matches `GetPromptResult` shape
|
|
519
|
+
- [ ] Constructor validation tests verify throws on invalid config
|
|
520
|
+
- [ ] Error classes are verified with `instanceof` checks and `mcpErrorCode` assertions
|
|
521
|
+
|
|
522
|
+
### E2E Tests
|
|
523
|
+
|
|
524
|
+
- [ ] Fixture-based tests use `test.use({ server, port })` for server lifecycle
|
|
525
|
+
- [ ] Tools appear in `tools/list` response via `toContainTool()` matcher
|
|
526
|
+
- [ ] Tool calls return expected results via `toBeSuccessful()` matcher
|
|
527
|
+
- [ ] Authenticated tests use `TestTokenFactory` and verify rejection without token
|
|
528
|
+
|
|
529
|
+
### CI Integration
|
|
530
|
+
|
|
531
|
+
- [ ] `nx test <lib> --coverage` passes locally with 95%+ on all metrics
|
|
532
|
+
- [ ] Unused imports are cleaned via `node scripts/fix-unused-imports.mjs`
|
|
533
|
+
- [ ] No TypeScript warnings in test files
|
|
534
|
+
|
|
535
|
+
## Troubleshooting
|
|
518
536
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
537
|
+
| Problem | Cause | Solution |
|
|
538
|
+
| -------------------------------------------- | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
539
|
+
| Jest cannot find test files | Files use `.test.ts` instead of `.spec.ts` | Rename to `.spec.ts`; Nx test runner only picks up `.spec.ts` by default |
|
|
540
|
+
| Coverage below 95% threshold | Untested branches or constructor paths | Run `nx test <lib> --coverage` and check the HTML report for uncovered lines |
|
|
541
|
+
| E2E test times out on `TestServer.start()` | Server entrypoint fails to start or wrong port | Verify `server` path and `port` in `test.use()`; check server logs for startup errors |
|
|
542
|
+
| `toContainTool` matcher not found | Using `expect` from Jest instead of `@frontmcp/testing` | Import `expect` from `@frontmcp/testing` to get MCP-specific matchers |
|
|
543
|
+
| `McpTestClient.create()` connection refused | Test server not running or wrong `baseUrl` | Ensure `TestServer.start()` completes before creating client; verify port matches |
|
|
544
|
+
| Istanbul shows 0% coverage for async methods | TypeScript compilation source-map mismatch | Known issue with `ts-jest` and certain async patterns; check `tsconfig.spec.json` source-map settings |
|
|
545
|
+
| Auth E2E test returns 401 unexpectedly | Token not set or expired | Call `mcp.setAuthToken(token)` before the tool call; use `auth.createToken()` with valid claims |
|
|
526
546
|
|
|
527
547
|
## Reference
|
|
528
548
|
|
|
529
|
-
- Testing
|
|
530
|
-
-
|
|
531
|
-
- Test client builder: `McpTestClient.builder()` — fluent API for test setup
|
|
532
|
-
- MCP matchers: `toContainTool()`, `toBeSuccessful()` — import from `@frontmcp/testing`
|
|
533
|
-
- Test fixtures: `createTestFixture()` — import from `@frontmcp/testing`
|
|
534
|
-
- Test server: `TestServer` — import from `@frontmcp/testing`
|
|
535
|
-
- Performance testing: `perfTest()`, `MetricsCollector` — import from `@frontmcp/testing`
|
|
536
|
-
- Auth testing: `TestTokenFactory`, `MockOAuthServer` — import from `@frontmcp/testing`
|
|
537
|
-
- Interceptors: `TestInterceptor` — import from `@frontmcp/testing`
|
|
538
|
-
- HTTP mocking: `HttpMock` — import from `@frontmcp/testing`
|
|
539
|
-
- [Source code on GitHub](https://github.com/agentfront/frontmcp/tree/main/libs/testing)
|
|
549
|
+
- [Testing Documentation](https://docs.agentfront.dev/frontmcp/testing/overview)
|
|
550
|
+
- Related skills: `create-tool`, `create-resource`, `create-prompt`, `setup-project`, `nx-workflow`
|