@tsdevstack/cli-mcp 0.1.4

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.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -0
  3. package/dist/context/index.d.ts +10 -0
  4. package/dist/index.d.ts +13 -0
  5. package/dist/index.js +1211 -0
  6. package/dist/mcp-serve.d.ts +7 -0
  7. package/dist/register-commands.d.ts +8 -0
  8. package/dist/resources/guide-config.d.ts +8 -0
  9. package/dist/resources/guide-nest-common.d.ts +9 -0
  10. package/dist/resources/guide-workflows.d.ts +8 -0
  11. package/dist/resources/guide.d.ts +8 -0
  12. package/dist/resources/guide.test.d.ts +1 -0
  13. package/dist/resources/kong-routes.d.ts +8 -0
  14. package/dist/resources/kong-routes.test.d.ts +1 -0
  15. package/dist/resources/project-state.d.ts +9 -0
  16. package/dist/resources/project-state.test.d.ts +1 -0
  17. package/dist/resources/register-resources.d.ts +7 -0
  18. package/dist/resources/secrets-context.d.ts +9 -0
  19. package/dist/resources/secrets-context.test.d.ts +1 -0
  20. package/dist/server.d.ts +7 -0
  21. package/dist/server.test.d.ts +1 -0
  22. package/dist/tools/action/action-tools.test.d.ts +1 -0
  23. package/dist/tools/action/add-service.d.ts +7 -0
  24. package/dist/tools/action/cloud-init.d.ts +7 -0
  25. package/dist/tools/action/cloud-secrets-push.d.ts +7 -0
  26. package/dist/tools/action/cloud-secrets-remove.d.ts +7 -0
  27. package/dist/tools/action/cloud-secrets-set.d.ts +7 -0
  28. package/dist/tools/action/deploy-kong.d.ts +7 -0
  29. package/dist/tools/action/deploy-lb.d.ts +7 -0
  30. package/dist/tools/action/deploy-scheduler.d.ts +7 -0
  31. package/dist/tools/action/deploy-schedulers.d.ts +7 -0
  32. package/dist/tools/action/deploy-service.d.ts +7 -0
  33. package/dist/tools/action/deploy-services.d.ts +7 -0
  34. package/dist/tools/action/generate-client.d.ts +7 -0
  35. package/dist/tools/action/generate-docker-compose.d.ts +7 -0
  36. package/dist/tools/action/generate-kong.d.ts +7 -0
  37. package/dist/tools/action/generate-secrets.d.ts +7 -0
  38. package/dist/tools/action/infra-bootstrap.d.ts +7 -0
  39. package/dist/tools/action/infra-build-docker.d.ts +7 -0
  40. package/dist/tools/action/infra-build-kong.d.ts +7 -0
  41. package/dist/tools/action/infra-deploy.d.ts +7 -0
  42. package/dist/tools/action/infra-destroy.d.ts +7 -0
  43. package/dist/tools/action/infra-generate-ci.d.ts +7 -0
  44. package/dist/tools/action/infra-generate-docker.d.ts +7 -0
  45. package/dist/tools/action/infra-generate.d.ts +7 -0
  46. package/dist/tools/action/infra-init-ci.d.ts +7 -0
  47. package/dist/tools/action/infra-init.d.ts +7 -0
  48. package/dist/tools/action/infra-push-docker.d.ts +7 -0
  49. package/dist/tools/action/register-detached-worker.d.ts +7 -0
  50. package/dist/tools/action/register.d.ts +7 -0
  51. package/dist/tools/action/remove-detached-worker.d.ts +7 -0
  52. package/dist/tools/action/remove-scheduler.d.ts +7 -0
  53. package/dist/tools/action/remove-service-cloud.d.ts +7 -0
  54. package/dist/tools/action/remove-service.d.ts +7 -0
  55. package/dist/tools/action/run-db-migrate.d.ts +7 -0
  56. package/dist/tools/action/sync.d.ts +7 -0
  57. package/dist/tools/action/unregister-detached-worker.d.ts +7 -0
  58. package/dist/tools/action/validate-service.d.ts +7 -0
  59. package/dist/tools/query/diff-secrets.d.ts +7 -0
  60. package/dist/tools/query/get-infrastructure-config.d.ts +7 -0
  61. package/dist/tools/query/get-project-config.d.ts +7 -0
  62. package/dist/tools/query/get-secret.d.ts +7 -0
  63. package/dist/tools/query/get-service-status.d.ts +7 -0
  64. package/dist/tools/query/infra-plan.d.ts +7 -0
  65. package/dist/tools/query/infra-status.d.ts +7 -0
  66. package/dist/tools/query/list-deployed-services.d.ts +7 -0
  67. package/dist/tools/query/list-environments.d.ts +7 -0
  68. package/dist/tools/query/list-schedulers.d.ts +7 -0
  69. package/dist/tools/query/list-secrets.d.ts +7 -0
  70. package/dist/tools/query/list-services.d.ts +7 -0
  71. package/dist/tools/query/plan-db-migrate.d.ts +7 -0
  72. package/dist/tools/query/query-tools.test.d.ts +1 -0
  73. package/dist/tools/query/register.d.ts +7 -0
  74. package/dist/tools/register-tools.d.ts +7 -0
  75. package/dist/utils/run-command.d.ts +8 -0
  76. package/dist/utils/run-command.test.d.ts +1 -0
  77. package/package.json +69 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 tsdevstack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # @tsdevstack/cli-mcp
2
+
3
+ MCP (Model Context Protocol) server plugin for the tsdevstack CLI. Exposes 48 tools and 12 resources so AI agents like Claude can manage infrastructure, deploy services, and query project state.
4
+
5
+ ## Features
6
+
7
+ - **48 MCP Tools** — 13 read-only queries + 35 actions covering the full tsdevstack CLI surface
8
+ - **12 MCP Resources** — project state, secrets context, Kong routes, and framework guides
9
+ - **Stdio Transport** — connects via stdin/stdout for IDE and agent integration
10
+ - **Zod Validation** — all tool inputs validated with schemas
11
+ - **MCP Annotations** — tools include `readOnlyHint`, `destructiveHint`, and `idempotentHint` metadata
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @tsdevstack/cli-mcp
17
+ ```
18
+
19
+ Requires `tsdevstack` as a peer dependency.
20
+
21
+ ## Usage
22
+
23
+ ### As a CLI plugin
24
+
25
+ The MCP server registers as a plugin with the tsdevstack CLI:
26
+
27
+ ```typescript
28
+ import { initContext, registerMcpPlugin } from '@tsdevstack/cli-mcp';
29
+
30
+ // Initialize with CLI plugin context
31
+ initContext(pluginContext);
32
+
33
+ // Register the mcp:serve command
34
+ registerMcpPlugin(program);
35
+ ```
36
+
37
+ ### Starting the server
38
+
39
+ ```bash
40
+ npx tsdevstack mcp:serve
41
+ ```
42
+
43
+ This starts the MCP server over stdio transport, ready for AI agent connections.
44
+
45
+ ### Claude Code integration
46
+
47
+ Add to your `.mcp.json`:
48
+
49
+ ```json
50
+ {
51
+ "mcpServers": {
52
+ "tsdevstack": {
53
+ "command": "npx",
54
+ "args": ["tsdevstack", "mcp:serve"]
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## Tools
61
+
62
+ ### Query tools (read-only)
63
+
64
+ | Tool | Description |
65
+ |------|-------------|
66
+ | `list_services` | List all services with types and ports |
67
+ | `list_environments` | List configured cloud environments |
68
+ | `get_project_config` | Full project configuration |
69
+ | `get_infrastructure_config` | Per-environment infrastructure settings |
70
+ | `get_service_status` | Cloud resource status for a service |
71
+ | `list_deployed_services` | All deployed services in an environment |
72
+ | `list_secrets` | Secret names in cloud (not values) |
73
+ | `diff_secrets` | Compare local vs cloud secrets |
74
+ | `get_secret` | Get a single secret value |
75
+ | `list_schedulers` | Scheduled jobs and status |
76
+ | `plan_db_migrate` | Preview pending database migrations |
77
+ | `infra_plan` | Terraform plan preview |
78
+ | `infra_status` | Infrastructure sync status |
79
+
80
+ ### Action tools — local
81
+
82
+ | Tool | Description |
83
+ |------|-------------|
84
+ | `sync` | Regenerate all local config |
85
+ | `generate_secrets` | Regenerate local secrets files |
86
+ | `generate_kong` | Regenerate Kong gateway config |
87
+ | `generate_docker_compose` | Regenerate docker-compose.yml |
88
+ | `add_service` | Add a new service (nestjs, nextjs, spa) |
89
+ | `remove_service` | Remove a service from the project |
90
+ | `generate_client` | Generate TypeScript HTTP client from OpenAPI |
91
+ | `register_detached_worker` | Register a detached worker in config |
92
+ | `unregister_detached_worker` | Remove a worker from config |
93
+
94
+ ### Action tools — cloud
95
+
96
+ | Tool | Description |
97
+ |------|-------------|
98
+ | `cloud_secrets_push` | Push secrets to cloud |
99
+ | `cloud_secrets_set` | Set a single cloud secret |
100
+ | `cloud_secrets_remove` | Remove a cloud secret |
101
+ | `infra_deploy` | Full infrastructure deployment |
102
+ | `deploy_services` | Deploy code changes to services |
103
+ | `deploy_service` | Build + push + deploy a single service |
104
+ | `deploy_kong` | Rebuild and deploy Kong gateway |
105
+ | `deploy_lb` | Deploy/update load balancer |
106
+ | `run_db_migrate` | Apply pending database migrations |
107
+ | `deploy_schedulers` | Deploy all scheduled jobs |
108
+ | `deploy_scheduler` | Deploy a single scheduled job |
109
+ | `remove_service_cloud` | Remove a service from cloud |
110
+ | `remove_detached_worker` | Remove a worker from cloud |
111
+ | `infra_destroy` | Destroy all cloud infrastructure |
112
+
113
+ ### Action tools — setup & CI
114
+
115
+ | Tool | Description |
116
+ |------|-------------|
117
+ | `cloud_init` | Initialize cloud provider credentials |
118
+ | `infra_bootstrap` | Bootstrap cloud project |
119
+ | `infra_init` | Initialize Terraform state |
120
+ | `infra_generate` | Generate Terraform files |
121
+ | `infra_generate_docker` | Generate Dockerfiles |
122
+ | `infra_build_docker` | Build Docker images |
123
+ | `infra_push_docker` | Push Docker images to registry |
124
+ | `infra_build_kong` | Build Kong Docker image |
125
+ | `infra_init_ci` | Initialize CI/CD workflows |
126
+ | `infra_generate_ci` | Regenerate CI workflows |
127
+ | `validate_service` | Validate service structure |
128
+ | `remove_scheduler` | Remove a scheduled job from cloud |
129
+
130
+ ## Resources
131
+
132
+ | Resource | Description |
133
+ |----------|-------------|
134
+ | Project state (8) | Services list, environments, config, infrastructure settings, deployed services, secrets, schedulers, migration status |
135
+ | Secrets context | Local and cloud secret names with diff |
136
+ | Kong routes | Current gateway routing configuration |
137
+ | Guides (4) | Framework guide, workflow guide, nest-common guide, config guide |
138
+
139
+ ## Architecture
140
+
141
+ The MCP server is a thin layer over the tsdevstack CLI:
142
+
143
+ - **Query tools** either read local config files directly or wrap `npx tsdevstack` commands
144
+ - **Action tools** delegate to `runCommand()` which spawns `npx tsdevstack <command>` as a child process
145
+ - **Resources** read project files and provide contextual documentation
146
+
147
+ Each tool is a single file with one registration function — following the tsdevstack one-function-per-file convention.
148
+
149
+ ## License
150
+
151
+ MIT
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Context Module
3
+ *
4
+ * Receives context from cli-core via initContext().
5
+ * Commands call getContext() to access utilities.
6
+ */
7
+ import type { PluginContext } from 'tsdevstack/plugin';
8
+ export declare function initContext(ctx: PluginContext): void;
9
+ export declare function getContext(): PluginContext;
10
+ export declare function wrapCommand<T extends unknown[]>(fn: (...args: T) => Promise<void>): (...args: T) => Promise<void>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * cli-mcp - MCP Server Plugin for tsdevstack CLI
3
+ *
4
+ * Exposes CLI commands as MCP tools so AI agents can manage
5
+ * infrastructure, deploy services, and query project state.
6
+ *
7
+ * Usage in cli.ts:
8
+ * import { initContext, registerMcpPlugin } from '@tsdevstack/cli-mcp';
9
+ * initContext(pluginContext);
10
+ * registerMcpPlugin(program);
11
+ */
12
+ export { initContext } from './context/index.js';
13
+ export { registerMcpPlugin } from './register-commands.js';