@sparkleideas/mcp 3.0.0-alpha.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.
Files changed (279) hide show
  1. package/.claude/agents/analysis/analyze-code-quality.md +179 -0
  2. package/.claude/agents/analysis/code-analyzer.md +210 -0
  3. package/.claude/agents/analysis/code-review/analyze-code-quality.md +179 -0
  4. package/.claude/agents/architecture/arch-system-design.md +157 -0
  5. package/.claude/agents/architecture/system-design/arch-system-design.md +155 -0
  6. package/.claude/agents/consensus/byzantine-coordinator.md +63 -0
  7. package/.claude/agents/consensus/crdt-synchronizer.md +997 -0
  8. package/.claude/agents/consensus/gossip-coordinator.md +63 -0
  9. package/.claude/agents/consensus/performance-benchmarker.md +851 -0
  10. package/.claude/agents/consensus/quorum-manager.md +823 -0
  11. package/.claude/agents/consensus/raft-manager.md +63 -0
  12. package/.claude/agents/consensus/security-manager.md +622 -0
  13. package/.claude/agents/core/coder.md +453 -0
  14. package/.claude/agents/core/planner.md +375 -0
  15. package/.claude/agents/core/researcher.md +369 -0
  16. package/.claude/agents/core/reviewer.md +520 -0
  17. package/.claude/agents/core/tester.md +512 -0
  18. package/.claude/agents/custom/test-long-runner.md +44 -0
  19. package/.claude/agents/data/data-ml-model.md +445 -0
  20. package/.claude/agents/data/ml/data-ml-model.md +193 -0
  21. package/.claude/agents/development/backend/dev-backend-api.md +142 -0
  22. package/.claude/agents/development/dev-backend-api.md +345 -0
  23. package/.claude/agents/devops/ci-cd/ops-cicd-github.md +164 -0
  24. package/.claude/agents/devops/ops-cicd-github.md +165 -0
  25. package/.claude/agents/documentation/api-docs/docs-api-openapi.md +174 -0
  26. package/.claude/agents/documentation/docs-api-openapi.md +355 -0
  27. package/.claude/agents/flow-nexus/app-store.md +88 -0
  28. package/.claude/agents/flow-nexus/authentication.md +69 -0
  29. package/.claude/agents/flow-nexus/challenges.md +81 -0
  30. package/.claude/agents/flow-nexus/neural-network.md +88 -0
  31. package/.claude/agents/flow-nexus/payments.md +83 -0
  32. package/.claude/agents/flow-nexus/sandbox.md +76 -0
  33. package/.claude/agents/flow-nexus/swarm.md +76 -0
  34. package/.claude/agents/flow-nexus/user-tools.md +96 -0
  35. package/.claude/agents/flow-nexus/workflow.md +84 -0
  36. package/.claude/agents/github/code-review-swarm.md +377 -0
  37. package/.claude/agents/github/github-modes.md +173 -0
  38. package/.claude/agents/github/issue-tracker.md +576 -0
  39. package/.claude/agents/github/multi-repo-swarm.md +553 -0
  40. package/.claude/agents/github/pr-manager.md +438 -0
  41. package/.claude/agents/github/project-board-sync.md +509 -0
  42. package/.claude/agents/github/release-manager.md +605 -0
  43. package/.claude/agents/github/release-swarm.md +583 -0
  44. package/.claude/agents/github/repo-architect.md +398 -0
  45. package/.claude/agents/github/swarm-issue.md +573 -0
  46. package/.claude/agents/github/swarm-pr.md +428 -0
  47. package/.claude/agents/github/sync-coordinator.md +452 -0
  48. package/.claude/agents/github/workflow-automation.md +903 -0
  49. package/.claude/agents/goal/agent.md +816 -0
  50. package/.claude/agents/goal/goal-planner.md +73 -0
  51. package/.claude/agents/optimization/benchmark-suite.md +665 -0
  52. package/.claude/agents/optimization/load-balancer.md +431 -0
  53. package/.claude/agents/optimization/performance-monitor.md +672 -0
  54. package/.claude/agents/optimization/resource-allocator.md +674 -0
  55. package/.claude/agents/optimization/topology-optimizer.md +808 -0
  56. package/.claude/agents/payments/agentic-payments.md +126 -0
  57. package/.claude/agents/sona/sona-learning-optimizer.md +74 -0
  58. package/.claude/agents/sparc/architecture.md +699 -0
  59. package/.claude/agents/sparc/pseudocode.md +520 -0
  60. package/.claude/agents/sparc/refinement.md +802 -0
  61. package/.claude/agents/sparc/specification.md +478 -0
  62. package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +225 -0
  63. package/.claude/agents/specialized/spec-mobile-react-native.md +227 -0
  64. package/.claude/agents/sublinear/consensus-coordinator.md +338 -0
  65. package/.claude/agents/sublinear/matrix-optimizer.md +185 -0
  66. package/.claude/agents/sublinear/pagerank-analyzer.md +299 -0
  67. package/.claude/agents/sublinear/performance-optimizer.md +368 -0
  68. package/.claude/agents/sublinear/trading-predictor.md +246 -0
  69. package/.claude/agents/swarm/adaptive-coordinator.md +1127 -0
  70. package/.claude/agents/swarm/hierarchical-coordinator.md +710 -0
  71. package/.claude/agents/swarm/mesh-coordinator.md +963 -0
  72. package/.claude/agents/templates/automation-smart-agent.md +205 -0
  73. package/.claude/agents/templates/base-template-generator.md +268 -0
  74. package/.claude/agents/templates/coordinator-swarm-init.md +90 -0
  75. package/.claude/agents/templates/github-pr-manager.md +177 -0
  76. package/.claude/agents/templates/implementer-sparc-coder.md +259 -0
  77. package/.claude/agents/templates/memory-coordinator.md +187 -0
  78. package/.claude/agents/templates/orchestrator-task.md +139 -0
  79. package/.claude/agents/templates/performance-analyzer.md +199 -0
  80. package/.claude/agents/templates/sparc-coordinator.md +514 -0
  81. package/.claude/agents/testing/production-validator.md +395 -0
  82. package/.claude/agents/testing/tdd-london-swarm.md +244 -0
  83. package/.claude/agents/v3/adr-architect.md +184 -0
  84. package/.claude/agents/v3/aidefence-guardian.md +282 -0
  85. package/.claude/agents/v3/claims-authorizer.md +208 -0
  86. package/.claude/agents/v3/collective-intelligence-coordinator.md +993 -0
  87. package/.claude/agents/v3/ddd-domain-expert.md +220 -0
  88. package/.claude/agents/v3/injection-analyst.md +236 -0
  89. package/.claude/agents/v3/memory-specialist.md +995 -0
  90. package/.claude/agents/v3/performance-engineer.md +1233 -0
  91. package/.claude/agents/v3/pii-detector.md +151 -0
  92. package/.claude/agents/v3/reasoningbank-learner.md +213 -0
  93. package/.claude/agents/v3/security-architect-aidefence.md +410 -0
  94. package/.claude/agents/v3/security-architect.md +867 -0
  95. package/.claude/agents/v3/security-auditor.md +771 -0
  96. package/.claude/agents/v3/sparc-orchestrator.md +182 -0
  97. package/.claude/agents/v3/swarm-memory-manager.md +157 -0
  98. package/.claude/agents/v3/v3-integration-architect.md +205 -0
  99. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
  100. package/.claude/commands/analysis/README.md +9 -0
  101. package/.claude/commands/analysis/bottleneck-detect.md +162 -0
  102. package/.claude/commands/analysis/performance-bottlenecks.md +59 -0
  103. package/.claude/commands/analysis/performance-report.md +25 -0
  104. package/.claude/commands/analysis/token-efficiency.md +45 -0
  105. package/.claude/commands/analysis/token-usage.md +25 -0
  106. package/.claude/commands/automation/README.md +9 -0
  107. package/.claude/commands/automation/auto-agent.md +122 -0
  108. package/.claude/commands/automation/self-healing.md +106 -0
  109. package/.claude/commands/automation/session-memory.md +90 -0
  110. package/.claude/commands/automation/smart-agents.md +73 -0
  111. package/.claude/commands/automation/smart-spawn.md +25 -0
  112. package/.claude/commands/automation/workflow-select.md +25 -0
  113. package/.claude/commands/claude-flow-help.md +103 -0
  114. package/.claude/commands/claude-flow-memory.md +107 -0
  115. package/.claude/commands/claude-flow-swarm.md +205 -0
  116. package/.claude/commands/github/README.md +11 -0
  117. package/.claude/commands/github/code-review-swarm.md +514 -0
  118. package/.claude/commands/github/code-review.md +25 -0
  119. package/.claude/commands/github/github-modes.md +147 -0
  120. package/.claude/commands/github/github-swarm.md +121 -0
  121. package/.claude/commands/github/issue-tracker.md +292 -0
  122. package/.claude/commands/github/issue-triage.md +25 -0
  123. package/.claude/commands/github/multi-repo-swarm.md +519 -0
  124. package/.claude/commands/github/pr-enhance.md +26 -0
  125. package/.claude/commands/github/pr-manager.md +170 -0
  126. package/.claude/commands/github/project-board-sync.md +471 -0
  127. package/.claude/commands/github/release-manager.md +338 -0
  128. package/.claude/commands/github/release-swarm.md +544 -0
  129. package/.claude/commands/github/repo-analyze.md +25 -0
  130. package/.claude/commands/github/repo-architect.md +367 -0
  131. package/.claude/commands/github/swarm-issue.md +482 -0
  132. package/.claude/commands/github/swarm-pr.md +285 -0
  133. package/.claude/commands/github/sync-coordinator.md +301 -0
  134. package/.claude/commands/github/workflow-automation.md +442 -0
  135. package/.claude/commands/hooks/README.md +11 -0
  136. package/.claude/commands/hooks/overview.md +58 -0
  137. package/.claude/commands/hooks/post-edit.md +117 -0
  138. package/.claude/commands/hooks/post-task.md +112 -0
  139. package/.claude/commands/hooks/pre-edit.md +113 -0
  140. package/.claude/commands/hooks/pre-task.md +111 -0
  141. package/.claude/commands/hooks/session-end.md +118 -0
  142. package/.claude/commands/hooks/setup.md +103 -0
  143. package/.claude/commands/monitoring/README.md +9 -0
  144. package/.claude/commands/monitoring/agent-metrics.md +25 -0
  145. package/.claude/commands/monitoring/agents.md +44 -0
  146. package/.claude/commands/monitoring/real-time-view.md +25 -0
  147. package/.claude/commands/monitoring/status.md +46 -0
  148. package/.claude/commands/monitoring/swarm-monitor.md +25 -0
  149. package/.claude/commands/optimization/README.md +9 -0
  150. package/.claude/commands/optimization/auto-topology.md +62 -0
  151. package/.claude/commands/optimization/cache-manage.md +25 -0
  152. package/.claude/commands/optimization/parallel-execute.md +25 -0
  153. package/.claude/commands/optimization/parallel-execution.md +50 -0
  154. package/.claude/commands/optimization/topology-optimize.md +25 -0
  155. package/.claude/commands/sparc/analyzer.md +52 -0
  156. package/.claude/commands/sparc/architect.md +53 -0
  157. package/.claude/commands/sparc/ask.md +97 -0
  158. package/.claude/commands/sparc/batch-executor.md +54 -0
  159. package/.claude/commands/sparc/code.md +89 -0
  160. package/.claude/commands/sparc/coder.md +54 -0
  161. package/.claude/commands/sparc/debug.md +83 -0
  162. package/.claude/commands/sparc/debugger.md +54 -0
  163. package/.claude/commands/sparc/designer.md +53 -0
  164. package/.claude/commands/sparc/devops.md +109 -0
  165. package/.claude/commands/sparc/docs-writer.md +80 -0
  166. package/.claude/commands/sparc/documenter.md +54 -0
  167. package/.claude/commands/sparc/innovator.md +54 -0
  168. package/.claude/commands/sparc/integration.md +83 -0
  169. package/.claude/commands/sparc/mcp.md +117 -0
  170. package/.claude/commands/sparc/memory-manager.md +54 -0
  171. package/.claude/commands/sparc/optimizer.md +54 -0
  172. package/.claude/commands/sparc/orchestrator.md +132 -0
  173. package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -0
  174. package/.claude/commands/sparc/refinement-optimization-mode.md +83 -0
  175. package/.claude/commands/sparc/researcher.md +54 -0
  176. package/.claude/commands/sparc/reviewer.md +54 -0
  177. package/.claude/commands/sparc/security-review.md +80 -0
  178. package/.claude/commands/sparc/sparc-modes.md +174 -0
  179. package/.claude/commands/sparc/sparc.md +111 -0
  180. package/.claude/commands/sparc/spec-pseudocode.md +80 -0
  181. package/.claude/commands/sparc/supabase-admin.md +348 -0
  182. package/.claude/commands/sparc/swarm-coordinator.md +54 -0
  183. package/.claude/commands/sparc/tdd.md +54 -0
  184. package/.claude/commands/sparc/tester.md +54 -0
  185. package/.claude/commands/sparc/tutorial.md +79 -0
  186. package/.claude/commands/sparc/workflow-manager.md +54 -0
  187. package/.claude/helpers/README.md +97 -0
  188. package/.claude/helpers/adr-compliance.sh +186 -0
  189. package/.claude/helpers/auto-commit.sh +178 -0
  190. package/.claude/helpers/checkpoint-manager.sh +251 -0
  191. package/.claude/helpers/daemon-manager.sh +252 -0
  192. package/.claude/helpers/ddd-tracker.sh +144 -0
  193. package/.claude/helpers/github-safe.js +106 -0
  194. package/.claude/helpers/github-setup.sh +28 -0
  195. package/.claude/helpers/guidance-hook.sh +13 -0
  196. package/.claude/helpers/guidance-hooks.sh +102 -0
  197. package/.claude/helpers/health-monitor.sh +108 -0
  198. package/.claude/helpers/learning-hooks.sh +329 -0
  199. package/.claude/helpers/learning-optimizer.sh +127 -0
  200. package/.claude/helpers/learning-service.mjs +1144 -0
  201. package/.claude/helpers/memory.js +83 -0
  202. package/.claude/helpers/metrics-db.mjs +488 -0
  203. package/.claude/helpers/pattern-consolidator.sh +86 -0
  204. package/.claude/helpers/perf-worker.sh +160 -0
  205. package/.claude/helpers/post-commit +16 -0
  206. package/.claude/helpers/pre-commit +26 -0
  207. package/.claude/helpers/quick-start.sh +19 -0
  208. package/.claude/helpers/router.js +66 -0
  209. package/.claude/helpers/security-scanner.sh +127 -0
  210. package/.claude/helpers/session.js +127 -0
  211. package/.claude/helpers/setup-mcp.sh +18 -0
  212. package/.claude/helpers/standard-checkpoint-hooks.sh +189 -0
  213. package/.claude/helpers/statusline-hook.sh +21 -0
  214. package/.claude/helpers/statusline.cjs +509 -0
  215. package/.claude/helpers/statusline.js +316 -0
  216. package/.claude/helpers/swarm-comms.sh +353 -0
  217. package/.claude/helpers/swarm-hooks.sh +761 -0
  218. package/.claude/helpers/swarm-monitor.sh +211 -0
  219. package/.claude/helpers/sync-v3-metrics.sh +245 -0
  220. package/.claude/helpers/update-v3-progress.sh +166 -0
  221. package/.claude/helpers/v3-quick-status.sh +58 -0
  222. package/.claude/helpers/v3.sh +111 -0
  223. package/.claude/helpers/validate-v3-config.sh +216 -0
  224. package/.claude/helpers/worker-manager.sh +170 -0
  225. package/.claude/settings.json +237 -0
  226. package/.claude/skills/agentdb-advanced/SKILL.md +550 -0
  227. package/.claude/skills/agentdb-learning/SKILL.md +545 -0
  228. package/.claude/skills/agentdb-memory-patterns/SKILL.md +339 -0
  229. package/.claude/skills/agentdb-optimization/SKILL.md +509 -0
  230. package/.claude/skills/agentdb-vector-search/SKILL.md +339 -0
  231. package/.claude/skills/github-code-review/SKILL.md +1140 -0
  232. package/.claude/skills/github-multi-repo/SKILL.md +874 -0
  233. package/.claude/skills/github-project-management/SKILL.md +1277 -0
  234. package/.claude/skills/github-release-management/SKILL.md +1081 -0
  235. package/.claude/skills/github-workflow-automation/SKILL.md +1065 -0
  236. package/.claude/skills/hooks-automation/SKILL.md +1201 -0
  237. package/.claude/skills/pair-programming/SKILL.md +1202 -0
  238. package/.claude/skills/reasoningbank-agentdb/SKILL.md +446 -0
  239. package/.claude/skills/reasoningbank-intelligence/SKILL.md +201 -0
  240. package/.claude/skills/skill-builder/SKILL.md +910 -0
  241. package/.claude/skills/sparc-methodology/SKILL.md +1115 -0
  242. package/.claude/skills/stream-chain/SKILL.md +563 -0
  243. package/.claude/skills/swarm-advanced/SKILL.md +973 -0
  244. package/.claude/skills/swarm-orchestration/SKILL.md +179 -0
  245. package/.claude/skills/v3-cli-modernization/SKILL.md +872 -0
  246. package/.claude/skills/v3-core-implementation/SKILL.md +797 -0
  247. package/.claude/skills/v3-ddd-architecture/SKILL.md +442 -0
  248. package/.claude/skills/v3-integration-deep/SKILL.md +241 -0
  249. package/.claude/skills/v3-mcp-optimization/SKILL.md +777 -0
  250. package/.claude/skills/v3-memory-unification/SKILL.md +174 -0
  251. package/.claude/skills/v3-performance-optimization/SKILL.md +390 -0
  252. package/.claude/skills/v3-security-overhaul/SKILL.md +82 -0
  253. package/.claude/skills/v3-swarm-coordination/SKILL.md +340 -0
  254. package/.claude/skills/verification-quality/SKILL.md +649 -0
  255. package/CLAUDE.md +711 -0
  256. package/README.md +428 -0
  257. package/__tests__/integration.test.ts +449 -0
  258. package/__tests__/mcp.test.ts +641 -0
  259. package/package.json +44 -0
  260. package/src/connection-pool.ts +344 -0
  261. package/src/index.ts +253 -0
  262. package/src/oauth.ts +447 -0
  263. package/src/prompt-registry.ts +296 -0
  264. package/src/rate-limiter.ts +266 -0
  265. package/src/resource-registry.ts +530 -0
  266. package/src/sampling.ts +363 -0
  267. package/src/schema-validator.ts +213 -0
  268. package/src/server.ts +1134 -0
  269. package/src/session-manager.ts +339 -0
  270. package/src/task-manager.ts +427 -0
  271. package/src/tool-registry.ts +475 -0
  272. package/src/transport/http.ts +532 -0
  273. package/src/transport/index.ts +233 -0
  274. package/src/transport/stdio.ts +252 -0
  275. package/src/transport/websocket.ts +396 -0
  276. package/src/types.ts +664 -0
  277. package/tmp.json +0 -0
  278. package/tsconfig.json +20 -0
  279. package/vitest.config.ts +13 -0
package/src/types.ts ADDED
@@ -0,0 +1,664 @@
1
+ /**
2
+ * @sparkleideas/mcp - Standalone Types
3
+ *
4
+ * Complete type definitions for MCP server implementation
5
+ * Zero external @claude-flow dependencies
6
+ */
7
+
8
+ // ============================================================================
9
+ // Core Protocol Types
10
+ // ============================================================================
11
+
12
+ export type JsonRpcVersion = '2.0';
13
+
14
+ export interface MCPProtocolVersion {
15
+ major: number;
16
+ minor: number;
17
+ patch: number;
18
+ }
19
+
20
+ export type RequestId = string | number | null;
21
+
22
+ export interface MCPMessage {
23
+ jsonrpc: JsonRpcVersion;
24
+ }
25
+
26
+ export interface MCPRequest extends MCPMessage {
27
+ id: RequestId;
28
+ method: string;
29
+ params?: Record<string, unknown>;
30
+ }
31
+
32
+ export interface MCPNotification extends MCPMessage {
33
+ method: string;
34
+ params?: Record<string, unknown>;
35
+ }
36
+
37
+ export interface MCPError {
38
+ code: number;
39
+ message: string;
40
+ data?: unknown;
41
+ }
42
+
43
+ export interface MCPResponse extends MCPMessage {
44
+ id: RequestId;
45
+ result?: unknown;
46
+ error?: MCPError;
47
+ }
48
+
49
+ // ============================================================================
50
+ // Server Configuration
51
+ // ============================================================================
52
+
53
+ export type TransportType = 'stdio' | 'http' | 'websocket' | 'in-process';
54
+
55
+ export type AuthMethod = 'token' | 'oauth' | 'api-key' | 'none';
56
+
57
+ export interface AuthConfig {
58
+ enabled: boolean;
59
+ method: AuthMethod;
60
+ tokens?: string[];
61
+ apiKeys?: string[];
62
+ jwtSecret?: string;
63
+ oauth?: {
64
+ clientId: string;
65
+ clientSecret: string;
66
+ authorizationUrl: string;
67
+ tokenUrl: string;
68
+ };
69
+ }
70
+
71
+ export interface LoadBalancerConfig {
72
+ enabled: boolean;
73
+ maxConcurrentRequests: number;
74
+ rateLimit?: {
75
+ requestsPerSecond: number;
76
+ burstSize: number;
77
+ };
78
+ circuitBreaker?: {
79
+ failureThreshold: number;
80
+ resetTimeout: number;
81
+ };
82
+ }
83
+
84
+ export interface ConnectionPoolConfig {
85
+ maxConnections: number;
86
+ minConnections: number;
87
+ idleTimeout: number;
88
+ acquireTimeout: number;
89
+ maxWaitingClients: number;
90
+ evictionRunInterval: number;
91
+ }
92
+
93
+ export interface MCPServerConfig {
94
+ name: string;
95
+ version: string;
96
+ transport: TransportType;
97
+ host?: string;
98
+ port?: number;
99
+ tlsEnabled?: boolean;
100
+ tlsCert?: string;
101
+ tlsKey?: string;
102
+ auth?: AuthConfig;
103
+ loadBalancer?: LoadBalancerConfig;
104
+ connectionPool?: ConnectionPoolConfig;
105
+ corsEnabled?: boolean;
106
+ corsOrigins?: string[];
107
+ maxRequestSize?: number;
108
+ requestTimeout?: number;
109
+ enableMetrics?: boolean;
110
+ enableCaching?: boolean;
111
+ cacheTTL?: number;
112
+ logLevel?: 'debug' | 'info' | 'warn' | 'error';
113
+ }
114
+
115
+ // ============================================================================
116
+ // Session Types
117
+ // ============================================================================
118
+
119
+ export type SessionState = 'created' | 'initializing' | 'ready' | 'closing' | 'closed' | 'error';
120
+
121
+ export interface MCPSession {
122
+ id: string;
123
+ state: SessionState;
124
+ transport: TransportType;
125
+ createdAt: Date;
126
+ lastActivityAt: Date;
127
+ isInitialized: boolean;
128
+ isAuthenticated: boolean;
129
+ clientInfo?: MCPClientInfo;
130
+ protocolVersion?: MCPProtocolVersion;
131
+ capabilities?: MCPCapabilities;
132
+ metadata?: Record<string, unknown>;
133
+ }
134
+
135
+ export interface MCPClientInfo {
136
+ name: string;
137
+ version: string;
138
+ }
139
+
140
+ // ============================================================================
141
+ // Capability Types
142
+ // ============================================================================
143
+
144
+ export interface MCPCapabilities {
145
+ logging?: {
146
+ level: 'debug' | 'info' | 'warn' | 'error';
147
+ };
148
+ tools?: {
149
+ listChanged: boolean;
150
+ };
151
+ resources?: {
152
+ listChanged: boolean;
153
+ subscribe: boolean;
154
+ };
155
+ prompts?: {
156
+ listChanged: boolean;
157
+ };
158
+ sampling?: Record<string, unknown>;
159
+ experimental?: Record<string, unknown>;
160
+ }
161
+
162
+ export interface MCPInitializeParams {
163
+ protocolVersion: MCPProtocolVersion;
164
+ capabilities: MCPCapabilities;
165
+ clientInfo: MCPClientInfo;
166
+ }
167
+
168
+ export interface MCPInitializeResult {
169
+ protocolVersion: MCPProtocolVersion;
170
+ capabilities: MCPCapabilities;
171
+ serverInfo: {
172
+ name: string;
173
+ version: string;
174
+ };
175
+ instructions?: string;
176
+ }
177
+
178
+ // ============================================================================
179
+ // Tool Types
180
+ // ============================================================================
181
+
182
+ export interface JSONSchema {
183
+ type: string;
184
+ properties?: Record<string, JSONSchema>;
185
+ required?: string[];
186
+ items?: JSONSchema;
187
+ enum?: string[];
188
+ description?: string;
189
+ default?: unknown;
190
+ minimum?: number;
191
+ maximum?: number;
192
+ minLength?: number;
193
+ maxLength?: number;
194
+ pattern?: string;
195
+ additionalProperties?: boolean | JSONSchema;
196
+ }
197
+
198
+ export interface ToolContext {
199
+ sessionId: string;
200
+ requestId?: RequestId;
201
+ orchestrator?: unknown;
202
+ swarmCoordinator?: unknown;
203
+ agentManager?: unknown;
204
+ resourceManager?: unknown;
205
+ messageBus?: unknown;
206
+ monitor?: unknown;
207
+ metadata?: Record<string, unknown>;
208
+ }
209
+
210
+ export type ToolHandler<TInput = unknown, TOutput = unknown> = (
211
+ input: TInput,
212
+ context?: ToolContext
213
+ ) => Promise<TOutput>;
214
+
215
+ export interface MCPTool<TInput = unknown, TOutput = unknown> {
216
+ name: string;
217
+ description: string;
218
+ inputSchema: JSONSchema;
219
+ handler: ToolHandler<TInput, TOutput>;
220
+ category?: string;
221
+ tags?: string[];
222
+ version?: string;
223
+ deprecated?: boolean;
224
+ cacheable?: boolean;
225
+ cacheTTL?: number;
226
+ timeout?: number;
227
+ }
228
+
229
+ export interface ToolCallResult {
230
+ content: Array<{
231
+ type: 'text' | 'image' | 'resource';
232
+ text?: string;
233
+ data?: string;
234
+ mimeType?: string;
235
+ }>;
236
+ isError: boolean;
237
+ }
238
+
239
+ export interface ToolRegistrationOptions {
240
+ override?: boolean;
241
+ validate?: boolean;
242
+ preload?: boolean;
243
+ }
244
+
245
+ // ============================================================================
246
+ // Resource Types (MCP 2025-11-25)
247
+ // ============================================================================
248
+
249
+ export interface MCPResource {
250
+ uri: string;
251
+ name: string;
252
+ description?: string;
253
+ mimeType?: string;
254
+ annotations?: ContentAnnotations;
255
+ }
256
+
257
+ export interface ResourceContent {
258
+ uri: string;
259
+ mimeType?: string;
260
+ text?: string;
261
+ blob?: string; // base64 encoded
262
+ }
263
+
264
+ export interface ResourceTemplate {
265
+ uriTemplate: string;
266
+ name: string;
267
+ description?: string;
268
+ mimeType?: string;
269
+ }
270
+
271
+ export interface ResourceListResult {
272
+ resources: MCPResource[];
273
+ nextCursor?: string;
274
+ }
275
+
276
+ export interface ResourceReadResult {
277
+ contents: ResourceContent[];
278
+ }
279
+
280
+ // ============================================================================
281
+ // Prompt Types (MCP 2025-11-25)
282
+ // ============================================================================
283
+
284
+ export interface PromptArgument {
285
+ name: string;
286
+ description?: string;
287
+ required?: boolean;
288
+ }
289
+
290
+ export interface MCPPrompt {
291
+ name: string;
292
+ title?: string;
293
+ description?: string;
294
+ arguments?: PromptArgument[];
295
+ }
296
+
297
+ export type PromptRole = 'user' | 'assistant';
298
+
299
+ export interface ContentAnnotations {
300
+ audience?: Array<'user' | 'assistant'>;
301
+ priority?: number;
302
+ createdAt?: string;
303
+ modifiedAt?: string;
304
+ }
305
+
306
+ export interface TextContent {
307
+ type: 'text';
308
+ text: string;
309
+ annotations?: ContentAnnotations;
310
+ }
311
+
312
+ export interface ImageContent {
313
+ type: 'image';
314
+ data: string; // base64
315
+ mimeType: string;
316
+ annotations?: ContentAnnotations;
317
+ }
318
+
319
+ export interface AudioContent {
320
+ type: 'audio';
321
+ data: string; // base64
322
+ mimeType: string;
323
+ annotations?: ContentAnnotations;
324
+ }
325
+
326
+ export interface EmbeddedResource {
327
+ type: 'resource';
328
+ resource: ResourceContent;
329
+ annotations?: ContentAnnotations;
330
+ }
331
+
332
+ export type PromptContent = TextContent | ImageContent | AudioContent | EmbeddedResource;
333
+
334
+ export interface PromptMessage {
335
+ role: PromptRole;
336
+ content: PromptContent;
337
+ }
338
+
339
+ export interface PromptListResult {
340
+ prompts: MCPPrompt[];
341
+ nextCursor?: string;
342
+ }
343
+
344
+ export interface PromptGetResult {
345
+ description?: string;
346
+ messages: PromptMessage[];
347
+ }
348
+
349
+ // ============================================================================
350
+ // Task Types (MCP 2025-11-25 - Async Operations)
351
+ // ============================================================================
352
+
353
+ export type TaskState = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
354
+
355
+ export interface MCPTask {
356
+ id: string;
357
+ state: TaskState;
358
+ progress?: TaskProgress;
359
+ result?: unknown;
360
+ error?: MCPError;
361
+ createdAt: Date;
362
+ updatedAt: Date;
363
+ metadata?: Record<string, unknown>;
364
+ }
365
+
366
+ export interface TaskProgress {
367
+ progress: number;
368
+ total?: number;
369
+ message?: string;
370
+ }
371
+
372
+ export interface TaskResult {
373
+ taskId: string;
374
+ state: TaskState;
375
+ progress?: TaskProgress;
376
+ result?: unknown;
377
+ error?: MCPError;
378
+ }
379
+
380
+ // ============================================================================
381
+ // Pagination Types (MCP 2025-11-25)
382
+ // ============================================================================
383
+
384
+ export interface PaginatedRequest {
385
+ cursor?: string;
386
+ }
387
+
388
+ export interface PaginatedResult<T> {
389
+ items: T[];
390
+ nextCursor?: string;
391
+ }
392
+
393
+ // ============================================================================
394
+ // Progress & Cancellation Types (MCP 2025-11-25)
395
+ // ============================================================================
396
+
397
+ export interface ProgressNotification {
398
+ progressToken: string | number;
399
+ progress: number;
400
+ total?: number;
401
+ message?: string;
402
+ }
403
+
404
+ export interface CancellationParams {
405
+ requestId: RequestId;
406
+ reason?: string;
407
+ }
408
+
409
+ // ============================================================================
410
+ // Sampling Types (MCP 2025-11-25 - Server-initiated LLM)
411
+ // ============================================================================
412
+
413
+ export interface SamplingMessage {
414
+ role: PromptRole;
415
+ content: PromptContent;
416
+ }
417
+
418
+ export interface ModelPreferences {
419
+ hints?: Array<{ name?: string }>;
420
+ costPriority?: number;
421
+ speedPriority?: number;
422
+ intelligencePriority?: number;
423
+ }
424
+
425
+ export interface CreateMessageRequest {
426
+ messages: SamplingMessage[];
427
+ modelPreferences?: ModelPreferences;
428
+ systemPrompt?: string;
429
+ includeContext?: 'none' | 'thisServer' | 'allServers';
430
+ temperature?: number;
431
+ maxTokens: number;
432
+ stopSequences?: string[];
433
+ metadata?: Record<string, unknown>;
434
+ }
435
+
436
+ export interface CreateMessageResult {
437
+ role: 'assistant';
438
+ content: PromptContent;
439
+ model: string;
440
+ stopReason?: 'endTurn' | 'stopSequence' | 'maxTokens';
441
+ }
442
+
443
+ // ============================================================================
444
+ // Roots Types (MCP 2025-11-25)
445
+ // ============================================================================
446
+
447
+ export interface Root {
448
+ uri: string;
449
+ name?: string;
450
+ }
451
+
452
+ export interface RootsListResult {
453
+ roots: Root[];
454
+ }
455
+
456
+ // ============================================================================
457
+ // Logging Types (MCP 2025-11-25)
458
+ // ============================================================================
459
+
460
+ export type MCPLogLevel = 'debug' | 'info' | 'notice' | 'warning' | 'error' | 'critical' | 'alert' | 'emergency';
461
+
462
+ export interface LoggingMessage {
463
+ level: MCPLogLevel;
464
+ logger?: string;
465
+ data?: unknown;
466
+ }
467
+
468
+ // ============================================================================
469
+ // Completion Types (MCP 2025-11-25)
470
+ // ============================================================================
471
+
472
+ export interface CompletionReference {
473
+ type: 'ref/prompt' | 'ref/resource';
474
+ name?: string;
475
+ uri?: string;
476
+ }
477
+
478
+ export interface CompletionArgument {
479
+ name: string;
480
+ value: string;
481
+ }
482
+
483
+ export interface CompletionResult {
484
+ values: string[];
485
+ total?: number;
486
+ hasMore?: boolean;
487
+ }
488
+
489
+ // ============================================================================
490
+ // Transport Types
491
+ // ============================================================================
492
+
493
+ export type RequestHandler = (request: MCPRequest) => Promise<MCPResponse>;
494
+
495
+ export type NotificationHandler = (notification: MCPNotification) => Promise<void>;
496
+
497
+ export interface TransportHealthStatus {
498
+ healthy: boolean;
499
+ error?: string;
500
+ metrics?: Record<string, number>;
501
+ }
502
+
503
+ export interface ITransport {
504
+ readonly type: TransportType;
505
+ start(): Promise<void>;
506
+ stop(): Promise<void>;
507
+ onRequest(handler: RequestHandler): void;
508
+ onNotification(handler: NotificationHandler): void;
509
+ sendNotification?(notification: MCPNotification): Promise<void>;
510
+ getHealthStatus(): Promise<TransportHealthStatus>;
511
+ }
512
+
513
+ // ============================================================================
514
+ // Connection Pool Types
515
+ // ============================================================================
516
+
517
+ export type ConnectionState = 'idle' | 'busy' | 'closing' | 'closed' | 'error';
518
+
519
+ export interface PooledConnection {
520
+ id: string;
521
+ state: ConnectionState;
522
+ createdAt: Date;
523
+ lastUsedAt: Date;
524
+ useCount: number;
525
+ transport: TransportType;
526
+ metadata?: Record<string, unknown>;
527
+ }
528
+
529
+ export interface ConnectionPoolStats {
530
+ totalConnections: number;
531
+ idleConnections: number;
532
+ busyConnections: number;
533
+ pendingRequests: number;
534
+ totalAcquired: number;
535
+ totalReleased: number;
536
+ totalCreated: number;
537
+ totalDestroyed: number;
538
+ avgAcquireTime: number;
539
+ }
540
+
541
+ export interface IConnectionPool {
542
+ acquire(): Promise<PooledConnection>;
543
+ release(connection: PooledConnection): void;
544
+ destroy(connection: PooledConnection): void;
545
+ getStats(): ConnectionPoolStats;
546
+ drain(): Promise<void>;
547
+ clear(): Promise<void>;
548
+ }
549
+
550
+ // ============================================================================
551
+ // Metrics Types
552
+ // ============================================================================
553
+
554
+ export interface ToolCallMetrics {
555
+ toolName: string;
556
+ duration: number;
557
+ success: boolean;
558
+ timestamp: number;
559
+ transport: TransportType;
560
+ cached?: boolean;
561
+ }
562
+
563
+ export interface MCPServerMetrics {
564
+ totalRequests: number;
565
+ successfulRequests: number;
566
+ failedRequests: number;
567
+ averageResponseTime: number;
568
+ activeSessions: number;
569
+ toolInvocations: Record<string, number>;
570
+ errors: Record<string, number>;
571
+ lastReset: Date;
572
+ startupTime?: number;
573
+ uptime?: number;
574
+ }
575
+
576
+ export interface SessionMetrics {
577
+ total: number;
578
+ active: number;
579
+ authenticated: number;
580
+ expired: number;
581
+ }
582
+
583
+ // ============================================================================
584
+ // Event Types
585
+ // ============================================================================
586
+
587
+ export type MCPEventType =
588
+ | 'server:started'
589
+ | 'server:stopped'
590
+ | 'server:error'
591
+ | 'session:created'
592
+ | 'session:initialized'
593
+ | 'session:closed'
594
+ | 'session:error'
595
+ | 'tool:registered'
596
+ | 'tool:unregistered'
597
+ | 'tool:called'
598
+ | 'tool:completed'
599
+ | 'tool:error'
600
+ | 'transport:connected'
601
+ | 'transport:disconnected'
602
+ | 'transport:error'
603
+ | 'pool:connection:acquired'
604
+ | 'pool:connection:released'
605
+ | 'pool:connection:created'
606
+ | 'pool:connection:destroyed';
607
+
608
+ export interface MCPEvent {
609
+ type: MCPEventType;
610
+ timestamp: Date;
611
+ data?: unknown;
612
+ }
613
+
614
+ export type EventHandler = (event: MCPEvent) => void;
615
+
616
+ // ============================================================================
617
+ // Logger Interface
618
+ // ============================================================================
619
+
620
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
621
+
622
+ export interface ILogger {
623
+ debug(message: string, data?: unknown): void;
624
+ info(message: string, data?: unknown): void;
625
+ warn(message: string, data?: unknown): void;
626
+ error(message: string, data?: unknown): void;
627
+ }
628
+
629
+ // ============================================================================
630
+ // Error Codes
631
+ // ============================================================================
632
+
633
+ export const ErrorCodes = {
634
+ PARSE_ERROR: -32700,
635
+ INVALID_REQUEST: -32600,
636
+ METHOD_NOT_FOUND: -32601,
637
+ INVALID_PARAMS: -32602,
638
+ INTERNAL_ERROR: -32603,
639
+ SERVER_NOT_INITIALIZED: -32002,
640
+ UNKNOWN_ERROR: -32001,
641
+ REQUEST_CANCELLED: -32800,
642
+ RATE_LIMITED: -32000,
643
+ AUTHENTICATION_REQUIRED: -32001,
644
+ AUTHORIZATION_FAILED: -32002,
645
+ } as const;
646
+
647
+ export class MCPServerError extends Error {
648
+ constructor(
649
+ message: string,
650
+ public code: number = ErrorCodes.INTERNAL_ERROR,
651
+ public data?: unknown
652
+ ) {
653
+ super(message);
654
+ this.name = 'MCPServerError';
655
+ }
656
+
657
+ toMCPError(): MCPError {
658
+ return {
659
+ code: this.code,
660
+ message: this.message,
661
+ data: this.data,
662
+ };
663
+ }
664
+ }
package/tmp.json ADDED
File without changes
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "dist", "__tests__"]
20
+ }
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ include: ['__tests__/**/*.test.ts'],
8
+ coverage: {
9
+ provider: 'v8',
10
+ reporter: ['text', 'json', 'html'],
11
+ },
12
+ },
13
+ });