nitrostack 1.0.0
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/CHANGELOG.md +227 -0
- package/CONTRIBUTING.md +182 -0
- package/LICENSE +201 -0
- package/LICENSE_URLS_UPDATE_COMPLETE.md +388 -0
- package/NOTICE +153 -0
- package/README.md +571 -0
- package/dist/auth/api-key.d.ts +118 -0
- package/dist/auth/api-key.d.ts.map +1 -0
- package/dist/auth/api-key.js +168 -0
- package/dist/auth/api-key.js.map +1 -0
- package/dist/auth/client.d.ts +151 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +330 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/index.d.ts +30 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +43 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +95 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +260 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/pkce.d.ts +53 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +105 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/quick-setup.d.ts +94 -0
- package/dist/auth/quick-setup.d.ts.map +1 -0
- package/dist/auth/quick-setup.js +210 -0
- package/dist/auth/quick-setup.js.map +1 -0
- package/dist/auth/server-integration.d.ts +97 -0
- package/dist/auth/server-integration.d.ts.map +1 -0
- package/dist/auth/server-integration.js +182 -0
- package/dist/auth/server-integration.js.map +1 -0
- package/dist/auth/server-metadata.d.ts +51 -0
- package/dist/auth/server-metadata.d.ts.map +1 -0
- package/dist/auth/server-metadata.js +106 -0
- package/dist/auth/server-metadata.js.map +1 -0
- package/dist/auth/simple-jwt.d.ts +88 -0
- package/dist/auth/simple-jwt.d.ts.map +1 -0
- package/dist/auth/simple-jwt.js +152 -0
- package/dist/auth/simple-jwt.js.map +1 -0
- package/dist/auth/token-store.d.ts +104 -0
- package/dist/auth/token-store.d.ts.map +1 -0
- package/dist/auth/token-store.js +205 -0
- package/dist/auth/token-store.js.map +1 -0
- package/dist/auth/token-validation.d.ts +47 -0
- package/dist/auth/token-validation.d.ts.map +1 -0
- package/dist/auth/token-validation.js +237 -0
- package/dist/auth/token-validation.js.map +1 -0
- package/dist/auth/types.d.ts +215 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +6 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli/commands/build.d.ts +6 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +104 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +7 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +312 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/generate-types.d.ts +8 -0
- package/dist/cli/commands/generate-types.d.ts.map +1 -0
- package/dist/cli/commands/generate-types.js +220 -0
- package/dist/cli/commands/generate-types.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +5 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +365 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/init.d.ts +7 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +365 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/start.d.ts +6 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +61 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +47 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/mcp-dev-wrapper.d.ts +3 -0
- package/dist/cli/mcp-dev-wrapper.d.ts.map +1 -0
- package/dist/cli/mcp-dev-wrapper.js +116 -0
- package/dist/cli/mcp-dev-wrapper.js.map +1 -0
- package/dist/core/apikey-module.d.ts +69 -0
- package/dist/core/apikey-module.d.ts.map +1 -0
- package/dist/core/apikey-module.js +114 -0
- package/dist/core/apikey-module.js.map +1 -0
- package/dist/core/app-decorator.d.ts +58 -0
- package/dist/core/app-decorator.d.ts.map +1 -0
- package/dist/core/app-decorator.js +261 -0
- package/dist/core/app-decorator.js.map +1 -0
- package/dist/core/builders.d.ts +38 -0
- package/dist/core/builders.d.ts.map +1 -0
- package/dist/core/builders.js +129 -0
- package/dist/core/builders.js.map +1 -0
- package/dist/core/component.d.ts +105 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/component.js +182 -0
- package/dist/core/component.js.map +1 -0
- package/dist/core/config-module.d.ts +55 -0
- package/dist/core/config-module.d.ts.map +1 -0
- package/dist/core/config-module.js +94 -0
- package/dist/core/config-module.js.map +1 -0
- package/dist/core/decorators/cache.decorator.d.ts +61 -0
- package/dist/core/decorators/cache.decorator.d.ts.map +1 -0
- package/dist/core/decorators/cache.decorator.js +115 -0
- package/dist/core/decorators/cache.decorator.js.map +1 -0
- package/dist/core/decorators/health-check.decorator.d.ts +80 -0
- package/dist/core/decorators/health-check.decorator.d.ts.map +1 -0
- package/dist/core/decorators/health-check.decorator.js +153 -0
- package/dist/core/decorators/health-check.decorator.js.map +1 -0
- package/dist/core/decorators/rate-limit.decorator.d.ts +62 -0
- package/dist/core/decorators/rate-limit.decorator.d.ts.map +1 -0
- package/dist/core/decorators/rate-limit.decorator.js +129 -0
- package/dist/core/decorators/rate-limit.decorator.js.map +1 -0
- package/dist/core/decorators.d.ts +151 -0
- package/dist/core/decorators.d.ts.map +1 -0
- package/dist/core/decorators.js +142 -0
- package/dist/core/decorators.js.map +1 -0
- package/dist/core/di/container.d.ts +42 -0
- package/dist/core/di/container.d.ts.map +1 -0
- package/dist/core/di/container.js +76 -0
- package/dist/core/di/container.js.map +1 -0
- package/dist/core/di/injectable.decorator.d.ts +35 -0
- package/dist/core/di/injectable.decorator.d.ts.map +1 -0
- package/dist/core/di/injectable.decorator.js +57 -0
- package/dist/core/di/injectable.decorator.js.map +1 -0
- package/dist/core/errors.d.ts +54 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +87 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/events/event-emitter.d.ts +50 -0
- package/dist/core/events/event-emitter.d.ts.map +1 -0
- package/dist/core/events/event-emitter.js +94 -0
- package/dist/core/events/event-emitter.js.map +1 -0
- package/dist/core/events/event.decorator.d.ts +48 -0
- package/dist/core/events/event.decorator.d.ts.map +1 -0
- package/dist/core/events/event.decorator.js +68 -0
- package/dist/core/events/event.decorator.js.map +1 -0
- package/dist/core/filters/exception-filter.decorator.d.ts +40 -0
- package/dist/core/filters/exception-filter.decorator.d.ts.map +1 -0
- package/dist/core/filters/exception-filter.decorator.js +54 -0
- package/dist/core/filters/exception-filter.decorator.js.map +1 -0
- package/dist/core/filters/exception-filter.interface.d.ts +30 -0
- package/dist/core/filters/exception-filter.interface.d.ts.map +1 -0
- package/dist/core/filters/exception-filter.interface.js +2 -0
- package/dist/core/filters/exception-filter.interface.js.map +1 -0
- package/dist/core/guards/apikey.guard.d.ts +22 -0
- package/dist/core/guards/apikey.guard.d.ts.map +1 -0
- package/dist/core/guards/apikey.guard.js +11 -0
- package/dist/core/guards/apikey.guard.js.map +1 -0
- package/dist/core/guards/guard.interface.d.ts +18 -0
- package/dist/core/guards/guard.interface.d.ts.map +1 -0
- package/dist/core/guards/guard.interface.js +2 -0
- package/dist/core/guards/guard.interface.js.map +1 -0
- package/dist/core/guards/jwt.guard.d.ts +18 -0
- package/dist/core/guards/jwt.guard.d.ts.map +1 -0
- package/dist/core/guards/jwt.guard.js +2 -0
- package/dist/core/guards/jwt.guard.js.map +1 -0
- package/dist/core/guards/oauth.guard.d.ts +35 -0
- package/dist/core/guards/oauth.guard.d.ts.map +1 -0
- package/dist/core/guards/oauth.guard.js +2 -0
- package/dist/core/guards/oauth.guard.js.map +1 -0
- package/dist/core/guards/use-guards.decorator.d.ts +25 -0
- package/dist/core/guards/use-guards.decorator.d.ts.map +1 -0
- package/dist/core/guards/use-guards.decorator.js +32 -0
- package/dist/core/guards/use-guards.decorator.js.map +1 -0
- package/dist/core/health/health-checks.resource.d.ts +14 -0
- package/dist/core/health/health-checks.resource.d.ts.map +1 -0
- package/dist/core/health/health-checks.resource.js +29 -0
- package/dist/core/health/health-checks.resource.js.map +1 -0
- package/dist/core/index.d.ts +55 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +57 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/interceptors/interceptor.decorator.d.ts +37 -0
- package/dist/core/interceptors/interceptor.decorator.d.ts.map +1 -0
- package/dist/core/interceptors/interceptor.decorator.js +51 -0
- package/dist/core/interceptors/interceptor.decorator.js.map +1 -0
- package/dist/core/interceptors/interceptor.interface.d.ts +31 -0
- package/dist/core/interceptors/interceptor.interface.d.ts.map +1 -0
- package/dist/core/interceptors/interceptor.interface.js +2 -0
- package/dist/core/interceptors/interceptor.interface.js.map +1 -0
- package/dist/core/jwt-module.d.ts +51 -0
- package/dist/core/jwt-module.d.ts.map +1 -0
- package/dist/core/jwt-module.js +52 -0
- package/dist/core/jwt-module.js.map +1 -0
- package/dist/core/logger.d.ts +18 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +51 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/middleware/middleware.decorator.d.ts +39 -0
- package/dist/core/middleware/middleware.decorator.d.ts.map +1 -0
- package/dist/core/middleware/middleware.decorator.js +53 -0
- package/dist/core/middleware/middleware.decorator.js.map +1 -0
- package/dist/core/middleware/middleware.interface.d.ts +29 -0
- package/dist/core/middleware/middleware.interface.d.ts.map +1 -0
- package/dist/core/middleware/middleware.interface.js +2 -0
- package/dist/core/middleware/middleware.interface.js.map +1 -0
- package/dist/core/module.d.ts +74 -0
- package/dist/core/module.d.ts.map +1 -0
- package/dist/core/module.js +82 -0
- package/dist/core/module.js.map +1 -0
- package/dist/core/oauth-module.d.ts +144 -0
- package/dist/core/oauth-module.d.ts.map +1 -0
- package/dist/core/oauth-module.js +190 -0
- package/dist/core/oauth-module.js.map +1 -0
- package/dist/core/pipes/pipe.decorator.d.ts +55 -0
- package/dist/core/pipes/pipe.decorator.d.ts.map +1 -0
- package/dist/core/pipes/pipe.decorator.js +85 -0
- package/dist/core/pipes/pipe.decorator.js.map +1 -0
- package/dist/core/pipes/pipe.interface.d.ts +36 -0
- package/dist/core/pipes/pipe.interface.d.ts.map +1 -0
- package/dist/core/pipes/pipe.interface.js +2 -0
- package/dist/core/pipes/pipe.interface.js.map +1 -0
- package/dist/core/prompt.d.ts +37 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +76 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/resource.d.ts +42 -0
- package/dist/core/resource.d.ts.map +1 -0
- package/dist/core/resource.js +90 -0
- package/dist/core/resource.js.map +1 -0
- package/dist/core/server.d.ts +72 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/server.js +406 -0
- package/dist/core/server.js.map +1 -0
- package/dist/core/tool.d.ts +78 -0
- package/dist/core/tool.d.ts.map +1 -0
- package/dist/core/tool.js +190 -0
- package/dist/core/tool.js.map +1 -0
- package/dist/core/transports/http-server.d.ts +102 -0
- package/dist/core/transports/http-server.d.ts.map +1 -0
- package/dist/core/transports/http-server.js +265 -0
- package/dist/core/transports/http-server.js.map +1 -0
- package/dist/core/types.d.ts +123 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/widgets/widget-examples.resource.d.ts +17 -0
- package/dist/core/widgets/widget-examples.resource.d.ts.map +1 -0
- package/dist/core/widgets/widget-examples.resource.js +28 -0
- package/dist/core/widgets/widget-examples.resource.js.map +1 -0
- package/dist/core/widgets/widget-registry.d.ts +56 -0
- package/dist/core/widgets/widget-registry.d.ts.map +1 -0
- package/dist/core/widgets/widget-registry.js +75 -0
- package/dist/core/widgets/widget-registry.js.map +1 -0
- package/dist/testing/index.d.ts +82 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +164 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/ui-next/index.d.ts +31 -0
- package/dist/ui-next/index.d.ts.map +1 -0
- package/dist/ui-next/index.js +687 -0
- package/dist/ui-next/index.js.map +1 -0
- package/dist/widgets/index.d.ts +9 -0
- package/dist/widgets/index.d.ts.map +1 -0
- package/dist/widgets/index.js +9 -0
- package/dist/widgets/index.js.map +1 -0
- package/dist/widgets/metadata.d.ts +53 -0
- package/dist/widgets/metadata.d.ts.map +1 -0
- package/dist/widgets/metadata.js +29 -0
- package/dist/widgets/metadata.js.map +1 -0
- package/dist/widgets/withToolData.d.ts +19 -0
- package/dist/widgets/withToolData.d.ts.map +1 -0
- package/dist/widgets/withToolData.js +240 -0
- package/dist/widgets/withToolData.js.map +1 -0
- package/jest.config.js +21 -0
- package/package.json +108 -0
- package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +702 -0
- package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-auth/README.md +400 -0
- package/templates/typescript-auth/package.json +44 -0
- package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-auth-api-key/README.md +483 -0
- package/templates/typescript-auth-api-key/package-lock.json +124 -0
- package/templates/typescript-auth-api-key/package.json +29 -0
- package/templates/typescript-oauth/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-oauth/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-oauth/OAUTH_SETUP.md +406 -0
- package/templates/typescript-oauth/README.md +350 -0
- package/templates/typescript-oauth/package.json +30 -0
- package/templates/typescript-starter/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-starter/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-starter/README.md +312 -0
- package/templates/typescript-starter/package.json +32 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { DIContainer } from './di/container.js';
|
|
2
|
+
export class Tool {
|
|
3
|
+
name;
|
|
4
|
+
description;
|
|
5
|
+
inputSchema;
|
|
6
|
+
examples;
|
|
7
|
+
widget;
|
|
8
|
+
outputTemplate;
|
|
9
|
+
handler;
|
|
10
|
+
guards;
|
|
11
|
+
middlewares;
|
|
12
|
+
interceptors;
|
|
13
|
+
pipes;
|
|
14
|
+
filters;
|
|
15
|
+
component;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.name = options.name;
|
|
18
|
+
this.description = options.description;
|
|
19
|
+
this.inputSchema = options.inputSchema;
|
|
20
|
+
this.handler = options.handler;
|
|
21
|
+
this.guards = options.guards || [];
|
|
22
|
+
this.middlewares = options.middlewares || [];
|
|
23
|
+
this.interceptors = options.interceptors || [];
|
|
24
|
+
this.pipes = options.pipes || [];
|
|
25
|
+
this.filters = options.filters || [];
|
|
26
|
+
this.examples = options.examples;
|
|
27
|
+
this.widget = options.widget;
|
|
28
|
+
this.outputTemplate = options.outputTemplate;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Execute the tool with full pipeline:
|
|
32
|
+
* Exception Filters -> Guards -> Middleware -> Interceptors -> Pipes -> Handler
|
|
33
|
+
*/
|
|
34
|
+
async execute(input, context) {
|
|
35
|
+
const container = DIContainer.getInstance();
|
|
36
|
+
try {
|
|
37
|
+
// 1. Execute Guards
|
|
38
|
+
for (const GuardClass of this.guards) {
|
|
39
|
+
const guard = container.has(GuardClass)
|
|
40
|
+
? container.resolve(GuardClass)
|
|
41
|
+
: new GuardClass();
|
|
42
|
+
const canActivate = await guard.canActivate(context);
|
|
43
|
+
if (!canActivate) {
|
|
44
|
+
throw new Error('Access denied by guard');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// 2. Build Middleware Chain
|
|
48
|
+
const middlewareChain = async (input) => {
|
|
49
|
+
let index = 0;
|
|
50
|
+
const middlewareInstances = this.middlewares.map(M => container.has(M) ? container.resolve(M) : new M());
|
|
51
|
+
const next = async () => {
|
|
52
|
+
if (index >= middlewareInstances.length) {
|
|
53
|
+
// 3. Build Interceptor Chain
|
|
54
|
+
return await this.executeWithInterceptors(input, context);
|
|
55
|
+
}
|
|
56
|
+
const middleware = middlewareInstances[index++];
|
|
57
|
+
return await middleware.use(context, next);
|
|
58
|
+
};
|
|
59
|
+
return await next();
|
|
60
|
+
};
|
|
61
|
+
return await middlewareChain(input);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// Execute Exception Filters
|
|
65
|
+
if (this.filters.length > 0) {
|
|
66
|
+
for (const FilterClass of this.filters) {
|
|
67
|
+
const filter = container.has(FilterClass)
|
|
68
|
+
? container.resolve(FilterClass)
|
|
69
|
+
: new FilterClass();
|
|
70
|
+
return await filter.catch(error, context);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Re-throw if no filters handled it
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Execute with interceptor chain
|
|
79
|
+
*/
|
|
80
|
+
async executeWithInterceptors(input, context) {
|
|
81
|
+
const container = DIContainer.getInstance();
|
|
82
|
+
let index = 0;
|
|
83
|
+
const interceptorInstances = this.interceptors.map(I => container.has(I) ? container.resolve(I) : new I());
|
|
84
|
+
const next = async () => {
|
|
85
|
+
if (index >= interceptorInstances.length) {
|
|
86
|
+
// 4. Execute Pipes, then Handler
|
|
87
|
+
return await this.executeWithPipes(input, context);
|
|
88
|
+
}
|
|
89
|
+
const interceptor = interceptorInstances[index++];
|
|
90
|
+
return await interceptor.intercept(context, next);
|
|
91
|
+
};
|
|
92
|
+
return await next();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Execute pipes and then the handler
|
|
96
|
+
*/
|
|
97
|
+
async executeWithPipes(input, context) {
|
|
98
|
+
const container = DIContainer.getInstance();
|
|
99
|
+
let transformedInput = input;
|
|
100
|
+
// Execute Pipes
|
|
101
|
+
for (const PipeClass of this.pipes) {
|
|
102
|
+
const pipe = container.has(PipeClass)
|
|
103
|
+
? container.resolve(PipeClass)
|
|
104
|
+
: new PipeClass();
|
|
105
|
+
transformedInput = await pipe.transform(transformedInput, {
|
|
106
|
+
type: 'body',
|
|
107
|
+
metatype: undefined,
|
|
108
|
+
data: undefined,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
// Finally, execute the actual handler
|
|
112
|
+
return await this.handler(transformedInput, context);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Attach a UI component to this tool
|
|
116
|
+
*/
|
|
117
|
+
setComponent(component) {
|
|
118
|
+
this.component = component;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Check if tool has a component
|
|
122
|
+
*/
|
|
123
|
+
hasComponent() {
|
|
124
|
+
return this.component !== undefined;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get the attached component
|
|
128
|
+
*/
|
|
129
|
+
getComponent() {
|
|
130
|
+
return this.component;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Convert to MCP tool format
|
|
134
|
+
*/
|
|
135
|
+
async toMcpTool() {
|
|
136
|
+
// Convert Zod schema to JSON Schema if needed
|
|
137
|
+
let jsonSchema = this.inputSchema;
|
|
138
|
+
// If it's a Zod schema, convert it
|
|
139
|
+
if (this.inputSchema && typeof this.inputSchema === 'object' && '_def' in this.inputSchema) {
|
|
140
|
+
// It's a Zod schema, need to convert to JSON Schema
|
|
141
|
+
try {
|
|
142
|
+
// Dynamic import for ES modules
|
|
143
|
+
const zodToJsonSchemaModule = await import('zod-to-json-schema');
|
|
144
|
+
const zodToJsonSchema = zodToJsonSchemaModule.zodToJsonSchema || zodToJsonSchemaModule.default;
|
|
145
|
+
// Convert with $refStrategy: 'none' to inline all properties
|
|
146
|
+
const converted = zodToJsonSchema(this.inputSchema, {
|
|
147
|
+
$refStrategy: 'none', // Don't use $refs, inline everything
|
|
148
|
+
target: 'jsonSchema7',
|
|
149
|
+
});
|
|
150
|
+
jsonSchema = converted;
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
// Error converting - use stderr to avoid corrupting MCP protocol
|
|
154
|
+
console.error('Error converting Zod schema:', error);
|
|
155
|
+
// Fallback: create a basic object schema
|
|
156
|
+
jsonSchema = {
|
|
157
|
+
type: 'object',
|
|
158
|
+
properties: {},
|
|
159
|
+
additionalProperties: true,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Ensure type is set to "object" if not present
|
|
164
|
+
if (!jsonSchema.type) {
|
|
165
|
+
jsonSchema = {
|
|
166
|
+
...jsonSchema,
|
|
167
|
+
type: 'object',
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
const mcpTool = {
|
|
171
|
+
name: this.name,
|
|
172
|
+
description: this.description,
|
|
173
|
+
inputSchema: jsonSchema,
|
|
174
|
+
};
|
|
175
|
+
// Include examples if available
|
|
176
|
+
if (this.examples) {
|
|
177
|
+
mcpTool.examples = this.examples;
|
|
178
|
+
}
|
|
179
|
+
// Include widget if available
|
|
180
|
+
if (this.widget) {
|
|
181
|
+
mcpTool.widget = this.widget;
|
|
182
|
+
}
|
|
183
|
+
// Include outputTemplate if available
|
|
184
|
+
if (this.outputTemplate) {
|
|
185
|
+
mcpTool.outputTemplate = this.outputTemplate;
|
|
186
|
+
}
|
|
187
|
+
return mcpTool;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/core/tool.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB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B,CAAC;CACF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Server Transport for MCP
|
|
3
|
+
*
|
|
4
|
+
* Implements HTTP transport with Server-Sent Events (SSE) for bidirectional communication.
|
|
5
|
+
* Required for OAuth 2.1 authentication as per MCP specification.
|
|
6
|
+
*
|
|
7
|
+
* This transport:
|
|
8
|
+
* - Exposes MCP over HTTP endpoints
|
|
9
|
+
* - Provides OAuth 2.1 metadata endpoints (RFC 9728)
|
|
10
|
+
* - Uses SSE for server-to-client messages
|
|
11
|
+
* - Uses POST for client-to-server messages
|
|
12
|
+
*/
|
|
13
|
+
import { Express } from 'express';
|
|
14
|
+
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
15
|
+
import { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
|
|
16
|
+
export interface HttpServerTransportOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Port to listen on (default: 3000)
|
|
19
|
+
*/
|
|
20
|
+
port?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Host to bind to (default: '0.0.0.0')
|
|
23
|
+
*/
|
|
24
|
+
host?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Base path for MCP endpoints (default: '/mcp')
|
|
27
|
+
*/
|
|
28
|
+
basePath?: string;
|
|
29
|
+
/**
|
|
30
|
+
* OAuth configuration (if enabled)
|
|
31
|
+
*/
|
|
32
|
+
oauth?: {
|
|
33
|
+
resourceUri: string;
|
|
34
|
+
authorizationServers: string[];
|
|
35
|
+
scopesSupported?: string[];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Custom Express app (optional - for integration with existing apps)
|
|
39
|
+
*/
|
|
40
|
+
app?: Express;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* HTTP Server Transport
|
|
44
|
+
*
|
|
45
|
+
* Implements MCP protocol over HTTP with SSE for real-time communication.
|
|
46
|
+
* Compatible with OAuth 2.1 authentication.
|
|
47
|
+
*/
|
|
48
|
+
export declare class HttpServerTransport implements Transport {
|
|
49
|
+
private app;
|
|
50
|
+
private server;
|
|
51
|
+
private sseClients;
|
|
52
|
+
private messageHandler?;
|
|
53
|
+
private closeHandler?;
|
|
54
|
+
private errorHandler?;
|
|
55
|
+
private options;
|
|
56
|
+
constructor(options?: HttpServerTransportOptions);
|
|
57
|
+
/**
|
|
58
|
+
* Setup HTTP routes for MCP protocol
|
|
59
|
+
*/
|
|
60
|
+
private setupRoutes;
|
|
61
|
+
/**
|
|
62
|
+
* Handle SSE connection for server-to-client messages
|
|
63
|
+
*/
|
|
64
|
+
private handleSSE;
|
|
65
|
+
/**
|
|
66
|
+
* Handle incoming message from client
|
|
67
|
+
*/
|
|
68
|
+
private handleMessage;
|
|
69
|
+
/**
|
|
70
|
+
* Handle OAuth Protected Resource Metadata request (RFC 9728)
|
|
71
|
+
*/
|
|
72
|
+
private handleProtectedResourceMetadata;
|
|
73
|
+
/**
|
|
74
|
+
* Start the HTTP server
|
|
75
|
+
*/
|
|
76
|
+
start(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Send message to client(s)
|
|
79
|
+
*/
|
|
80
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Close the transport
|
|
83
|
+
*/
|
|
84
|
+
close(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Set message handler
|
|
87
|
+
*/
|
|
88
|
+
set onmessage(handler: (message: JSONRPCMessage) => Promise<void>);
|
|
89
|
+
/**
|
|
90
|
+
* Set close handler
|
|
91
|
+
*/
|
|
92
|
+
set onclose(handler: () => void);
|
|
93
|
+
/**
|
|
94
|
+
* Set error handler
|
|
95
|
+
*/
|
|
96
|
+
set onerror(handler: (error: Error) => void);
|
|
97
|
+
/**
|
|
98
|
+
* Get the Express app (for adding custom routes)
|
|
99
|
+
*/
|
|
100
|
+
getApp(): Express;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=http-server.d.ts.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,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAclD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA2C5B;;OAEG;IACH,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,EAEhE;IAED;;OAEG;IACH,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,IAAI,EAE9B;IAED;;OAEG;IACH,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAE1C;IAED;;OAEG;IACH,MAAM,IAAI,OAAO;CAGlB"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Server Transport for MCP
|
|
3
|
+
*
|
|
4
|
+
* Implements HTTP transport with Server-Sent Events (SSE) for bidirectional communication.
|
|
5
|
+
* Required for OAuth 2.1 authentication as per MCP specification.
|
|
6
|
+
*
|
|
7
|
+
* This transport:
|
|
8
|
+
* - Exposes MCP over HTTP endpoints
|
|
9
|
+
* - Provides OAuth 2.1 metadata endpoints (RFC 9728)
|
|
10
|
+
* - Uses SSE for server-to-client messages
|
|
11
|
+
* - Uses POST for client-to-server messages
|
|
12
|
+
*/
|
|
13
|
+
import express from 'express';
|
|
14
|
+
/**
|
|
15
|
+
* HTTP Server Transport
|
|
16
|
+
*
|
|
17
|
+
* Implements MCP protocol over HTTP with SSE for real-time communication.
|
|
18
|
+
* Compatible with OAuth 2.1 authentication.
|
|
19
|
+
*/
|
|
20
|
+
export class HttpServerTransport {
|
|
21
|
+
app;
|
|
22
|
+
server = null;
|
|
23
|
+
sseClients = new Map();
|
|
24
|
+
messageHandler;
|
|
25
|
+
closeHandler;
|
|
26
|
+
errorHandler;
|
|
27
|
+
options;
|
|
28
|
+
constructor(options = {}) {
|
|
29
|
+
this.options = {
|
|
30
|
+
port: options.port || 3000,
|
|
31
|
+
host: options.host || '0.0.0.0',
|
|
32
|
+
basePath: options.basePath || '/mcp',
|
|
33
|
+
oauth: options.oauth,
|
|
34
|
+
};
|
|
35
|
+
this.app = options.app || express();
|
|
36
|
+
this.setupRoutes();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Setup HTTP routes for MCP protocol
|
|
40
|
+
*/
|
|
41
|
+
setupRoutes() {
|
|
42
|
+
const basePath = this.options.basePath;
|
|
43
|
+
// Enable CORS
|
|
44
|
+
this.app.use((req, res, next) => {
|
|
45
|
+
res.header('Access-Control-Allow-Origin', '*');
|
|
46
|
+
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
47
|
+
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
48
|
+
if (req.method === 'OPTIONS') {
|
|
49
|
+
res.sendStatus(200);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
next();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// JSON parsing
|
|
56
|
+
this.app.use(express.json());
|
|
57
|
+
// SSE endpoint for server-to-client messages
|
|
58
|
+
this.app.get(`${basePath}/sse`, (req, res) => {
|
|
59
|
+
this.handleSSE(req, res);
|
|
60
|
+
});
|
|
61
|
+
// POST endpoint for client-to-server messages
|
|
62
|
+
this.app.post(`${basePath}/message`, async (req, res) => {
|
|
63
|
+
await this.handleMessage(req, res);
|
|
64
|
+
});
|
|
65
|
+
// OAuth 2.1 Protected Resource Metadata (RFC 9728)
|
|
66
|
+
if (this.options.oauth) {
|
|
67
|
+
this.app.get('/.well-known/oauth-protected-resource', (req, res) => {
|
|
68
|
+
this.handleProtectedResourceMetadata(req, res);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Health check
|
|
72
|
+
this.app.get(`${basePath}/health`, (req, res) => {
|
|
73
|
+
res.json({ status: 'ok', transport: 'http' });
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Handle SSE connection for server-to-client messages
|
|
78
|
+
*/
|
|
79
|
+
handleSSE(req, res) {
|
|
80
|
+
const clientId = req.query.clientId || `client_${Date.now()}`;
|
|
81
|
+
// Setup SSE
|
|
82
|
+
res.writeHead(200, {
|
|
83
|
+
'Content-Type': 'text/event-stream',
|
|
84
|
+
'Cache-Control': 'no-cache',
|
|
85
|
+
'Connection': 'keep-alive',
|
|
86
|
+
});
|
|
87
|
+
// Store client
|
|
88
|
+
this.sseClients.set(clientId, res);
|
|
89
|
+
// Send initial connection event
|
|
90
|
+
res.write(`data: ${JSON.stringify({ type: 'connected', clientId })}\n\n`);
|
|
91
|
+
// Handle client disconnect
|
|
92
|
+
req.on('close', () => {
|
|
93
|
+
this.sseClients.delete(clientId);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Handle incoming message from client
|
|
98
|
+
*/
|
|
99
|
+
async handleMessage(req, res) {
|
|
100
|
+
try {
|
|
101
|
+
const message = req.body;
|
|
102
|
+
if (!message || !message.jsonrpc) {
|
|
103
|
+
res.status(400).json({ error: 'Invalid JSON-RPC message' });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Pass to message handler
|
|
107
|
+
if (this.messageHandler) {
|
|
108
|
+
await this.messageHandler(message);
|
|
109
|
+
}
|
|
110
|
+
res.json({ status: 'received' });
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error('Error handling message:', error);
|
|
114
|
+
res.status(500).json({ error: error.message });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Handle OAuth Protected Resource Metadata request (RFC 9728)
|
|
119
|
+
*/
|
|
120
|
+
handleProtectedResourceMetadata(req, res) {
|
|
121
|
+
if (!this.options.oauth) {
|
|
122
|
+
res.status(404).json({ error: 'OAuth not configured' });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const metadata = {
|
|
126
|
+
resource: this.options.oauth.resourceUri,
|
|
127
|
+
authorization_servers: this.options.oauth.authorizationServers,
|
|
128
|
+
...(this.options.oauth.scopesSupported && {
|
|
129
|
+
scopes_supported: this.options.oauth.scopesSupported,
|
|
130
|
+
}),
|
|
131
|
+
};
|
|
132
|
+
res.json(metadata);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Start the HTTP server
|
|
136
|
+
*/
|
|
137
|
+
async start() {
|
|
138
|
+
// Close existing server if any
|
|
139
|
+
if (this.server) {
|
|
140
|
+
await this.close();
|
|
141
|
+
}
|
|
142
|
+
return new Promise((resolve, reject) => {
|
|
143
|
+
// Set up error handler BEFORE calling listen
|
|
144
|
+
const errorHandler = (error) => {
|
|
145
|
+
console.error(`❌ Failed to start HTTP server: ${error.message}`);
|
|
146
|
+
this.server = null;
|
|
147
|
+
reject(error);
|
|
148
|
+
};
|
|
149
|
+
try {
|
|
150
|
+
const server = this.app.listen(this.options.port, this.options.host);
|
|
151
|
+
// Register error handler immediately
|
|
152
|
+
server.once('error', errorHandler);
|
|
153
|
+
// Success handler
|
|
154
|
+
server.once('listening', () => {
|
|
155
|
+
// Remove error handler since we're now listening
|
|
156
|
+
server.removeListener('error', errorHandler);
|
|
157
|
+
// Set up permanent error handler for runtime errors
|
|
158
|
+
server.on('error', (error) => {
|
|
159
|
+
if (this.errorHandler) {
|
|
160
|
+
this.errorHandler(error);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
console.error('HTTP server error:', error);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
this.server = server;
|
|
167
|
+
console.error(`🌐 HTTP MCP Server listening on http://${this.options.host}:${this.options.port}${this.options.basePath}`);
|
|
168
|
+
if (this.options.oauth) {
|
|
169
|
+
console.error(`🔐 OAuth 2.1 enabled`);
|
|
170
|
+
console.error(` Resource URI: ${this.options.oauth.resourceUri}`);
|
|
171
|
+
console.error(` Auth Servers: ${this.options.oauth.authorizationServers.join(', ')}`);
|
|
172
|
+
console.error(` Metadata: http://${this.options.host}:${this.options.port}/.well-known/oauth-protected-resource`);
|
|
173
|
+
}
|
|
174
|
+
resolve();
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
reject(error);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Send message to client(s)
|
|
184
|
+
*/
|
|
185
|
+
async send(message) {
|
|
186
|
+
const data = `data: ${JSON.stringify(message)}\n\n`;
|
|
187
|
+
// Send to all connected SSE clients
|
|
188
|
+
for (const [clientId, res] of this.sseClients) {
|
|
189
|
+
try {
|
|
190
|
+
res.write(data);
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
console.error(`Error sending to client ${clientId}:`, error);
|
|
194
|
+
this.sseClients.delete(clientId);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Close the transport
|
|
200
|
+
*/
|
|
201
|
+
async close() {
|
|
202
|
+
// Close all SSE connections
|
|
203
|
+
for (const [clientId, res] of this.sseClients) {
|
|
204
|
+
try {
|
|
205
|
+
res.end();
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
// Ignore errors on close
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
this.sseClients.clear();
|
|
212
|
+
// Close HTTP server
|
|
213
|
+
if (this.server) {
|
|
214
|
+
return new Promise((resolve) => {
|
|
215
|
+
const server = this.server;
|
|
216
|
+
this.server = null; // Clear reference immediately
|
|
217
|
+
// Force close all connections
|
|
218
|
+
server.closeAllConnections?.(); // Available in Node 18+
|
|
219
|
+
server.close((err) => {
|
|
220
|
+
if (err) {
|
|
221
|
+
console.error('HTTP server close error (ignoring):', err.message);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
console.error('🔌 HTTP MCP Server closed');
|
|
225
|
+
}
|
|
226
|
+
// Small delay to ensure port is fully released
|
|
227
|
+
setTimeout(() => {
|
|
228
|
+
if (this.closeHandler) {
|
|
229
|
+
this.closeHandler();
|
|
230
|
+
}
|
|
231
|
+
resolve();
|
|
232
|
+
}, 100);
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
if (this.closeHandler) {
|
|
237
|
+
this.closeHandler();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Set message handler
|
|
242
|
+
*/
|
|
243
|
+
set onmessage(handler) {
|
|
244
|
+
this.messageHandler = handler;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Set close handler
|
|
248
|
+
*/
|
|
249
|
+
set onclose(handler) {
|
|
250
|
+
this.closeHandler = handler;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Set error handler
|
|
254
|
+
*/
|
|
255
|
+
set onerror(handler) {
|
|
256
|
+
this.errorHandler = handler;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get the Express app (for adding custom routes)
|
|
260
|
+
*/
|
|
261
|
+
getApp() {
|
|
262
|
+
return this.app;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=http-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-server.js","sourceRoot":"","sources":["../../../src/core/transports/http-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,OAAuC,MAAM,SAAS,CAAC;AAoC9D;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IACtB,GAAG,CAAU;IACb,MAAM,GAAsB,IAAI,CAAC;IACjC,UAAU,GAA0B,IAAI,GAAG,EAAE,CAAC;IAC9C,cAAc,CAA8C;IAC5D,YAAY,CAAc;IAC1B,YAAY,CAA0B;IACtC,OAAO,CAAgH;IAE/H,YAAY,UAAsC,EAAE;QAClD,IAAI,CAAC,OAAO,GAAG;YACb,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,SAAS;YAC/B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