@vinkius-core/mcp-fusion 2.14.0 → 2.14.2
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/dist/cli/fusion.js +35 -35
- package/dist/cli/templates/config.js +26 -26
- package/dist/cli/templates/core.d.ts.map +1 -1
- package/dist/cli/templates/core.js +108 -111
- package/dist/cli/templates/core.js.map +1 -1
- package/dist/cli/templates/middleware.js +25 -25
- package/dist/cli/templates/readme.js +142 -142
- package/dist/cli/templates/testing.js +83 -83
- package/dist/cli/templates/tools.js +46 -46
- package/dist/cli/templates/vectors/database.js +69 -69
- package/dist/cli/templates/vectors/oauth.js +63 -63
- package/dist/cli/templates/vectors/openapi.js +97 -97
- package/dist/core/builder/ActionGroupBuilder.d.ts +6 -2
- package/dist/core/builder/ActionGroupBuilder.d.ts.map +1 -1
- package/dist/core/builder/ActionGroupBuilder.js +6 -2
- package/dist/core/builder/ActionGroupBuilder.js.map +1 -1
- package/dist/core/builder/FluentRouter.d.ts +6 -2
- package/dist/core/builder/FluentRouter.d.ts.map +1 -1
- package/dist/core/builder/FluentRouter.js +6 -2
- package/dist/core/builder/FluentRouter.js.map +1 -1
- package/dist/core/builder/FluentToolBuilder.d.ts +45 -9
- package/dist/core/builder/FluentToolBuilder.d.ts.map +1 -1
- package/dist/core/builder/FluentToolBuilder.js +54 -27
- package/dist/core/builder/FluentToolBuilder.js.map +1 -1
- package/dist/core/builder/GroupedToolBuilder.d.ts +32 -2
- package/dist/core/builder/GroupedToolBuilder.d.ts.map +1 -1
- package/dist/core/builder/GroupedToolBuilder.js +47 -2
- package/dist/core/builder/GroupedToolBuilder.js.map +1 -1
- package/dist/core/builder/defineTool.d.ts +5 -4
- package/dist/core/builder/defineTool.d.ts.map +1 -1
- package/dist/core/builder/defineTool.js +3 -2
- package/dist/core/builder/defineTool.js.map +1 -1
- package/dist/core/initFusion.d.ts +26 -1
- package/dist/core/initFusion.d.ts.map +1 -1
- package/dist/core/initFusion.js +5 -0
- package/dist/core/initFusion.js.map +1 -1
- package/dist/fsm/StateMachineGate.d.ts +264 -0
- package/dist/fsm/StateMachineGate.d.ts.map +1 -0
- package/dist/fsm/StateMachineGate.js +343 -0
- package/dist/fsm/StateMachineGate.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/introspection/SemanticProbe.js +49 -49
- package/dist/observability/TelemetryBus.d.ts +82 -0
- package/dist/observability/TelemetryBus.d.ts.map +1 -0
- package/dist/observability/TelemetryBus.js +335 -0
- package/dist/observability/TelemetryBus.js.map +1 -0
- package/dist/observability/TelemetryEvent.d.ts +171 -0
- package/dist/observability/TelemetryEvent.d.ts.map +1 -0
- package/dist/observability/TelemetryEvent.js +2 -0
- package/dist/observability/TelemetryEvent.js.map +1 -0
- package/dist/presenter/definePresenter.d.ts +2 -2
- package/dist/presenter/definePresenter.d.ts.map +1 -1
- package/dist/prompt/FluentPromptBuilder.d.ts.map +1 -1
- package/dist/server/ServerAttachment.d.ts +63 -0
- package/dist/server/ServerAttachment.d.ts.map +1 -1
- package/dist/server/ServerAttachment.js +149 -6
- package/dist/server/ServerAttachment.js.map +1 -1
- package/package.json +10 -3
|
@@ -4,79 +4,79 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/** Generate `prisma/schema.prisma` */
|
|
6
6
|
export function prismaSchema() {
|
|
7
|
-
return `// Prisma Schema — Database-Driven MCP Server
|
|
8
|
-
//
|
|
9
|
-
// The @vinkius-core/mcp-fusion-prisma-gen generator reads annotations
|
|
10
|
-
// and auto-generates Presenters + ToolBuilders with:
|
|
11
|
-
// - Field-level security (/// @fusion.hide)
|
|
12
|
-
// - Tenant isolation
|
|
13
|
-
// - OOM protection
|
|
14
|
-
|
|
15
|
-
generator client {
|
|
16
|
-
provider = "prisma-client-js"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
generator fusion {
|
|
20
|
-
provider = "@vinkius-core/mcp-fusion-prisma-gen"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
datasource db {
|
|
24
|
-
provider = "postgresql"
|
|
25
|
-
url = env("DATABASE_URL")
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
model User {
|
|
29
|
-
id String @id @default(cuid())
|
|
30
|
-
email String @unique
|
|
31
|
-
name String
|
|
32
|
-
|
|
33
|
-
/// @fusion.hide — Stripped by the Egress Firewall before reaching the LLM
|
|
34
|
-
password String
|
|
35
|
-
|
|
36
|
-
role String @default("USER")
|
|
37
|
-
createdAt DateTime @default(now())
|
|
38
|
-
updatedAt DateTime @updatedAt
|
|
39
|
-
|
|
40
|
-
posts Post[]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
model Post {
|
|
44
|
-
id String @id @default(cuid())
|
|
45
|
-
title String
|
|
46
|
-
content String?
|
|
47
|
-
published Boolean @default(false)
|
|
48
|
-
createdAt DateTime @default(now())
|
|
49
|
-
|
|
50
|
-
author User @relation(fields: [authorId], references: [id])
|
|
51
|
-
authorId String
|
|
52
|
-
}
|
|
7
|
+
return `// Prisma Schema — Database-Driven MCP Server
|
|
8
|
+
//
|
|
9
|
+
// The @vinkius-core/mcp-fusion-prisma-gen generator reads annotations
|
|
10
|
+
// and auto-generates Presenters + ToolBuilders with:
|
|
11
|
+
// - Field-level security (/// @fusion.hide)
|
|
12
|
+
// - Tenant isolation
|
|
13
|
+
// - OOM protection
|
|
14
|
+
|
|
15
|
+
generator client {
|
|
16
|
+
provider = "prisma-client-js"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
generator fusion {
|
|
20
|
+
provider = "@vinkius-core/mcp-fusion-prisma-gen"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
datasource db {
|
|
24
|
+
provider = "postgresql"
|
|
25
|
+
url = env("DATABASE_URL")
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
model User {
|
|
29
|
+
id String @id @default(cuid())
|
|
30
|
+
email String @unique
|
|
31
|
+
name String
|
|
32
|
+
|
|
33
|
+
/// @fusion.hide — Stripped by the Egress Firewall before reaching the LLM
|
|
34
|
+
password String
|
|
35
|
+
|
|
36
|
+
role String @default("USER")
|
|
37
|
+
createdAt DateTime @default(now())
|
|
38
|
+
updatedAt DateTime @updatedAt
|
|
39
|
+
|
|
40
|
+
posts Post[]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
model Post {
|
|
44
|
+
id String @id @default(cuid())
|
|
45
|
+
title String
|
|
46
|
+
content String?
|
|
47
|
+
published Boolean @default(false)
|
|
48
|
+
createdAt DateTime @default(now())
|
|
49
|
+
|
|
50
|
+
author User @relation(fields: [authorId], references: [id])
|
|
51
|
+
authorId String
|
|
52
|
+
}
|
|
53
53
|
`;
|
|
54
54
|
}
|
|
55
55
|
/** Generate `src/tools/db/users.ts` */
|
|
56
56
|
export function dbUsersToolTs() {
|
|
57
|
-
return `/**
|
|
58
|
-
* Database Users Tool — Prisma-Driven CRUD (Fluent API)
|
|
59
|
-
*
|
|
60
|
-
* Demonstrates:
|
|
61
|
-
* - f.query() with .withOptionalNumber() typed parameter
|
|
62
|
-
* - .handle(input, ctx) — input.take is typed as number | undefined
|
|
63
|
-
* - Implicit success() wrapping
|
|
64
|
-
*/
|
|
65
|
-
import { f } from '../../fusion.js';
|
|
66
|
-
|
|
67
|
-
export default f.query('db.list_users')
|
|
68
|
-
.describe('List users from the database')
|
|
69
|
-
.withOptionalNumber('take', 'Max results (1-50)')
|
|
70
|
-
.handle(async (input, ctx) => {
|
|
71
|
-
// TODO: Replace with your Prisma client
|
|
72
|
-
// const users = await ctx.db.user.findMany({ take: input.take ?? 10 });
|
|
73
|
-
// return users;
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
hint: 'Connect your Prisma client in src/context.ts to enable database queries.',
|
|
77
|
-
example: 'const users = await ctx.db.user.findMany({ take: 10 })',
|
|
78
|
-
};
|
|
79
|
-
});
|
|
57
|
+
return `/**
|
|
58
|
+
* Database Users Tool — Prisma-Driven CRUD (Fluent API)
|
|
59
|
+
*
|
|
60
|
+
* Demonstrates:
|
|
61
|
+
* - f.query() with .withOptionalNumber() typed parameter
|
|
62
|
+
* - .handle(input, ctx) — input.take is typed as number | undefined
|
|
63
|
+
* - Implicit success() wrapping
|
|
64
|
+
*/
|
|
65
|
+
import { f } from '../../fusion.js';
|
|
66
|
+
|
|
67
|
+
export default f.query('db.list_users')
|
|
68
|
+
.describe('List users from the database')
|
|
69
|
+
.withOptionalNumber('take', 'Max results (1-50)')
|
|
70
|
+
.handle(async (input, ctx) => {
|
|
71
|
+
// TODO: Replace with your Prisma client
|
|
72
|
+
// const users = await ctx.db.user.findMany({ take: input.take ?? 10 });
|
|
73
|
+
// return users;
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
hint: 'Connect your Prisma client in src/context.ts to enable database queries.',
|
|
77
|
+
example: 'const users = await ctx.db.user.findMany({ take: 10 })',
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
80
|
`;
|
|
81
81
|
}
|
|
82
82
|
//# sourceMappingURL=database.js.map
|
|
@@ -4,73 +4,73 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/** Generate `src/auth.ts` — OAuth Device Flow setup */
|
|
6
6
|
export function oauthSetupTs(config) {
|
|
7
|
-
return `/**
|
|
8
|
-
* OAuth Setup — Device Flow Authentication (RFC 8628)
|
|
9
|
-
*
|
|
10
|
-
* Pre-configured \`createAuthTool()\` with login, complete, status, logout actions.
|
|
11
|
-
* The \`requireAuth()\` middleware protects any tool with one line.
|
|
12
|
-
*
|
|
13
|
-
* 1. Set CLIENT_ID and AUTH endpoints in .env
|
|
14
|
-
* 2. Register the auth tool in server.ts
|
|
15
|
-
* 3. Use \`requireAuth()\` on protected tools
|
|
16
|
-
*/
|
|
17
|
-
import { createAuthTool, TokenManager } from '@vinkius-core/mcp-fusion-oauth';
|
|
18
|
-
import type { ToolRegistry } from '@vinkius-core/mcp-fusion';
|
|
19
|
-
|
|
20
|
-
export function registerAuth<TContext>(registry: ToolRegistry<TContext>): void {
|
|
21
|
-
const clientId = process.env['OAUTH_CLIENT_ID'];
|
|
22
|
-
const authEndpoint = process.env['OAUTH_AUTH_ENDPOINT'];
|
|
23
|
-
const tokenEndpoint = process.env['OAUTH_TOKEN_ENDPOINT'];
|
|
24
|
-
|
|
25
|
-
if (!clientId || !authEndpoint || !tokenEndpoint) {
|
|
26
|
-
console.error('⚠️ OAUTH_CLIENT_ID, OAUTH_AUTH_ENDPOINT, OAUTH_TOKEN_ENDPOINT are required in .env');
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const auth = createAuthTool({
|
|
31
|
-
clientId,
|
|
32
|
-
authorizationEndpoint: authEndpoint,
|
|
33
|
-
tokenEndpoint,
|
|
34
|
-
tokenManager: {
|
|
35
|
-
configDir: '.${config.name}',
|
|
36
|
-
envVar: '${config.name.toUpperCase().replace(/-/g, '_')}_TOKEN',
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
registry.register(auth);
|
|
41
|
-
console.error('🔐 OAuth Device Flow registered (auth.login → auth.complete → auth.status)');
|
|
42
|
-
}
|
|
7
|
+
return `/**
|
|
8
|
+
* OAuth Setup — Device Flow Authentication (RFC 8628)
|
|
9
|
+
*
|
|
10
|
+
* Pre-configured \`createAuthTool()\` with login, complete, status, logout actions.
|
|
11
|
+
* The \`requireAuth()\` middleware protects any tool with one line.
|
|
12
|
+
*
|
|
13
|
+
* 1. Set CLIENT_ID and AUTH endpoints in .env
|
|
14
|
+
* 2. Register the auth tool in server.ts
|
|
15
|
+
* 3. Use \`requireAuth()\` on protected tools
|
|
16
|
+
*/
|
|
17
|
+
import { createAuthTool, TokenManager } from '@vinkius-core/mcp-fusion-oauth';
|
|
18
|
+
import type { ToolRegistry } from '@vinkius-core/mcp-fusion';
|
|
19
|
+
|
|
20
|
+
export function registerAuth<TContext>(registry: ToolRegistry<TContext>): void {
|
|
21
|
+
const clientId = process.env['OAUTH_CLIENT_ID'];
|
|
22
|
+
const authEndpoint = process.env['OAUTH_AUTH_ENDPOINT'];
|
|
23
|
+
const tokenEndpoint = process.env['OAUTH_TOKEN_ENDPOINT'];
|
|
24
|
+
|
|
25
|
+
if (!clientId || !authEndpoint || !tokenEndpoint) {
|
|
26
|
+
console.error('⚠️ OAUTH_CLIENT_ID, OAUTH_AUTH_ENDPOINT, OAUTH_TOKEN_ENDPOINT are required in .env');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const auth = createAuthTool({
|
|
31
|
+
clientId,
|
|
32
|
+
authorizationEndpoint: authEndpoint,
|
|
33
|
+
tokenEndpoint,
|
|
34
|
+
tokenManager: {
|
|
35
|
+
configDir: '.${config.name}',
|
|
36
|
+
envVar: '${config.name.toUpperCase().replace(/-/g, '_')}_TOKEN',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
registry.register(auth);
|
|
41
|
+
console.error('🔐 OAuth Device Flow registered (auth.login → auth.complete → auth.status)');
|
|
42
|
+
}
|
|
43
43
|
`;
|
|
44
44
|
}
|
|
45
45
|
/** Generate `src/middleware/auth.ts` — requireAuth middleware */
|
|
46
46
|
export function oauthMiddlewareTs() {
|
|
47
|
-
return `/**
|
|
48
|
-
* Auth Middleware — Protect tools with requireAuth()
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* \`\`\`ts
|
|
52
|
-
* import { withAuth } from '../middleware/auth.js';
|
|
53
|
-
*
|
|
54
|
-
* export default f.query('projects.list')
|
|
55
|
-
* .describe('List all projects')
|
|
56
|
-
* .use(withAuth)
|
|
57
|
-
* .handle(async (input, ctx) => { /* authenticated */ });
|
|
58
|
-
* \`\`\`
|
|
59
|
-
*/
|
|
60
|
-
import { requireAuth } from '@vinkius-core/mcp-fusion-oauth';
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Pre-configured auth middleware.
|
|
64
|
-
* Rejects unauthenticated requests with \`AUTH_REQUIRED\` + self-healing hints.
|
|
65
|
-
*/
|
|
66
|
-
export const withAuth = requireAuth({
|
|
67
|
-
extractToken: (ctx: unknown) => {
|
|
68
|
-
const obj = ctx as Record<string, unknown>;
|
|
69
|
-
return typeof obj['token'] === 'string' ? obj['token'] : null;
|
|
70
|
-
},
|
|
71
|
-
recoveryHint: 'Call auth action=login to authenticate via browser',
|
|
72
|
-
recoveryAction: 'auth',
|
|
73
|
-
});
|
|
47
|
+
return `/**
|
|
48
|
+
* Auth Middleware — Protect tools with requireAuth()
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* \`\`\`ts
|
|
52
|
+
* import { withAuth } from '../middleware/auth.js';
|
|
53
|
+
*
|
|
54
|
+
* export default f.query('projects.list')
|
|
55
|
+
* .describe('List all projects')
|
|
56
|
+
* .use(withAuth)
|
|
57
|
+
* .handle(async (input, ctx) => { /* authenticated */ });
|
|
58
|
+
* \`\`\`
|
|
59
|
+
*/
|
|
60
|
+
import { requireAuth } from '@vinkius-core/mcp-fusion-oauth';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Pre-configured auth middleware.
|
|
64
|
+
* Rejects unauthenticated requests with \`AUTH_REQUIRED\` + self-healing hints.
|
|
65
|
+
*/
|
|
66
|
+
export const withAuth = requireAuth({
|
|
67
|
+
extractToken: (ctx: unknown) => {
|
|
68
|
+
const obj = ctx as Record<string, unknown>;
|
|
69
|
+
return typeof obj['token'] === 'string' ? obj['token'] : null;
|
|
70
|
+
},
|
|
71
|
+
recoveryHint: 'Call auth action=login to authenticate via browser',
|
|
72
|
+
recoveryAction: 'auth',
|
|
73
|
+
});
|
|
74
74
|
`;
|
|
75
75
|
}
|
|
76
76
|
//# sourceMappingURL=oauth.js.map
|
|
@@ -1,106 +1,106 @@
|
|
|
1
1
|
/** Generate `openapi.yaml` — Sample OpenAPI spec */
|
|
2
2
|
export function openapiYaml(config) {
|
|
3
|
-
return `# OpenAPI 3.0 Specification — Sample
|
|
4
|
-
#
|
|
5
|
-
# Replace this with your actual API spec, then run:
|
|
6
|
-
# npx @vinkius-core/mcp-fusion-openapi-gen ./openapi.yaml --outDir ./src/generated
|
|
7
|
-
#
|
|
8
|
-
# The generator creates Presenters, Tools, Registry, and server
|
|
9
|
-
# bootstrap — all configurable via YAML annotations.
|
|
10
|
-
|
|
11
|
-
openapi: '3.0.3'
|
|
12
|
-
info:
|
|
13
|
-
title: '${config.name} API'
|
|
14
|
-
version: '0.1.0'
|
|
15
|
-
description: Sample API for MCP Fusion OpenAPI generation
|
|
16
|
-
|
|
17
|
-
servers:
|
|
18
|
-
- url: http://localhost:3000/api
|
|
19
|
-
|
|
20
|
-
paths:
|
|
21
|
-
/health:
|
|
22
|
-
get:
|
|
23
|
-
operationId: getHealth
|
|
24
|
-
summary: Health check endpoint
|
|
25
|
-
responses:
|
|
26
|
-
'200':
|
|
27
|
-
description: Server health status
|
|
28
|
-
content:
|
|
29
|
-
application/json:
|
|
30
|
-
schema:
|
|
31
|
-
type: object
|
|
32
|
-
properties:
|
|
33
|
-
status:
|
|
34
|
-
type: string
|
|
35
|
-
example: healthy
|
|
36
|
-
uptime:
|
|
37
|
-
type: number
|
|
38
|
-
example: 12345.67
|
|
39
|
-
|
|
40
|
-
/users:
|
|
41
|
-
get:
|
|
42
|
-
operationId: listUsers
|
|
43
|
-
summary: List all users
|
|
44
|
-
parameters:
|
|
45
|
-
- name: limit
|
|
46
|
-
in: query
|
|
47
|
-
schema:
|
|
48
|
-
type: integer
|
|
49
|
-
minimum: 1
|
|
50
|
-
maximum: 100
|
|
51
|
-
default: 10
|
|
52
|
-
responses:
|
|
53
|
-
'200':
|
|
54
|
-
description: List of users
|
|
55
|
-
content:
|
|
56
|
-
application/json:
|
|
57
|
-
schema:
|
|
58
|
-
type: array
|
|
59
|
-
items:
|
|
60
|
-
$ref: '#/components/schemas/User'
|
|
61
|
-
|
|
62
|
-
components:
|
|
63
|
-
schemas:
|
|
64
|
-
User:
|
|
65
|
-
type: object
|
|
66
|
-
properties:
|
|
67
|
-
id:
|
|
68
|
-
type: string
|
|
69
|
-
name:
|
|
70
|
-
type: string
|
|
71
|
-
email:
|
|
72
|
-
type: string
|
|
3
|
+
return `# OpenAPI 3.0 Specification — Sample
|
|
4
|
+
#
|
|
5
|
+
# Replace this with your actual API spec, then run:
|
|
6
|
+
# npx @vinkius-core/mcp-fusion-openapi-gen ./openapi.yaml --outDir ./src/generated
|
|
7
|
+
#
|
|
8
|
+
# The generator creates Presenters, Tools, Registry, and server
|
|
9
|
+
# bootstrap — all configurable via YAML annotations.
|
|
10
|
+
|
|
11
|
+
openapi: '3.0.3'
|
|
12
|
+
info:
|
|
13
|
+
title: '${config.name} API'
|
|
14
|
+
version: '0.1.0'
|
|
15
|
+
description: Sample API for MCP Fusion OpenAPI generation
|
|
16
|
+
|
|
17
|
+
servers:
|
|
18
|
+
- url: http://localhost:3000/api
|
|
19
|
+
|
|
20
|
+
paths:
|
|
21
|
+
/health:
|
|
22
|
+
get:
|
|
23
|
+
operationId: getHealth
|
|
24
|
+
summary: Health check endpoint
|
|
25
|
+
responses:
|
|
26
|
+
'200':
|
|
27
|
+
description: Server health status
|
|
28
|
+
content:
|
|
29
|
+
application/json:
|
|
30
|
+
schema:
|
|
31
|
+
type: object
|
|
32
|
+
properties:
|
|
33
|
+
status:
|
|
34
|
+
type: string
|
|
35
|
+
example: healthy
|
|
36
|
+
uptime:
|
|
37
|
+
type: number
|
|
38
|
+
example: 12345.67
|
|
39
|
+
|
|
40
|
+
/users:
|
|
41
|
+
get:
|
|
42
|
+
operationId: listUsers
|
|
43
|
+
summary: List all users
|
|
44
|
+
parameters:
|
|
45
|
+
- name: limit
|
|
46
|
+
in: query
|
|
47
|
+
schema:
|
|
48
|
+
type: integer
|
|
49
|
+
minimum: 1
|
|
50
|
+
maximum: 100
|
|
51
|
+
default: 10
|
|
52
|
+
responses:
|
|
53
|
+
'200':
|
|
54
|
+
description: List of users
|
|
55
|
+
content:
|
|
56
|
+
application/json:
|
|
57
|
+
schema:
|
|
58
|
+
type: array
|
|
59
|
+
items:
|
|
60
|
+
$ref: '#/components/schemas/User'
|
|
61
|
+
|
|
62
|
+
components:
|
|
63
|
+
schemas:
|
|
64
|
+
User:
|
|
65
|
+
type: object
|
|
66
|
+
properties:
|
|
67
|
+
id:
|
|
68
|
+
type: string
|
|
69
|
+
name:
|
|
70
|
+
type: string
|
|
71
|
+
email:
|
|
72
|
+
type: string
|
|
73
73
|
`;
|
|
74
74
|
}
|
|
75
75
|
/** Generate `SETUP.md` — OpenAPI generation instructions */
|
|
76
76
|
export function openapiSetupMd() {
|
|
77
|
-
return `# OpenAPI Generator Setup
|
|
78
|
-
|
|
79
|
-
This project is configured for the **Legacy API Proxy** ingestion vector.
|
|
80
|
-
|
|
81
|
-
## Steps
|
|
82
|
-
|
|
83
|
-
1. Replace \`openapi.yaml\` with your actual OpenAPI 3.x spec
|
|
84
|
-
|
|
85
|
-
2. Generate the MCP server from the spec:
|
|
86
|
-
\`\`\`bash
|
|
87
|
-
npx @vinkius-core/mcp-fusion-openapi-gen ./openapi.yaml --outDir ./src/generated
|
|
88
|
-
\`\`\`
|
|
89
|
-
|
|
90
|
-
3. The generator creates:
|
|
91
|
-
- Presenters with Zod schemas (Egress Firewall)
|
|
92
|
-
- Tool builders with typed handlers
|
|
93
|
-
- Registry setup with all endpoints
|
|
94
|
-
|
|
95
|
-
4. Import and register in \`src/server.ts\`:
|
|
96
|
-
\`\`\`typescript
|
|
97
|
-
import { generatedTools } from './generated/registry.js';
|
|
98
|
-
registry.registerAll(...generatedTools);
|
|
99
|
-
\`\`\`
|
|
100
|
-
|
|
101
|
-
## Documentation
|
|
102
|
-
|
|
103
|
-
See: [OpenAPI Generator](https://mcp-fusion.vinkius.com/openapi-gen)
|
|
77
|
+
return `# OpenAPI Generator Setup
|
|
78
|
+
|
|
79
|
+
This project is configured for the **Legacy API Proxy** ingestion vector.
|
|
80
|
+
|
|
81
|
+
## Steps
|
|
82
|
+
|
|
83
|
+
1. Replace \`openapi.yaml\` with your actual OpenAPI 3.x spec
|
|
84
|
+
|
|
85
|
+
2. Generate the MCP server from the spec:
|
|
86
|
+
\`\`\`bash
|
|
87
|
+
npx @vinkius-core/mcp-fusion-openapi-gen ./openapi.yaml --outDir ./src/generated
|
|
88
|
+
\`\`\`
|
|
89
|
+
|
|
90
|
+
3. The generator creates:
|
|
91
|
+
- Presenters with Zod schemas (Egress Firewall)
|
|
92
|
+
- Tool builders with typed handlers
|
|
93
|
+
- Registry setup with all endpoints
|
|
94
|
+
|
|
95
|
+
4. Import and register in \`src/server.ts\`:
|
|
96
|
+
\`\`\`typescript
|
|
97
|
+
import { generatedTools } from './generated/registry.js';
|
|
98
|
+
registry.registerAll(...generatedTools);
|
|
99
|
+
\`\`\`
|
|
100
|
+
|
|
101
|
+
## Documentation
|
|
102
|
+
|
|
103
|
+
See: [OpenAPI Generator](https://mcp-fusion.vinkius.com/openapi-gen)
|
|
104
104
|
`;
|
|
105
105
|
}
|
|
106
106
|
//# sourceMappingURL=openapi.js.map
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import { type ZodObject, type ZodRawShape } from 'zod';
|
|
30
30
|
import { type ToolResponse, type InternalAction, type MiddlewareFn, type ActionConfig } from '../types.js';
|
|
31
|
+
import { type MiddlewareDefinition } from '../middleware/ContextDerivation.js';
|
|
31
32
|
/**
|
|
32
33
|
* Callback for configuring actions within a group.
|
|
33
34
|
*
|
|
@@ -79,7 +80,10 @@ export declare class ActionGroupBuilder<TContext, TCommon extends Record<string,
|
|
|
79
80
|
* Unlike {@link GroupedToolBuilder.use}, this middleware runs
|
|
80
81
|
* only for actions within this group — not globally.
|
|
81
82
|
*
|
|
82
|
-
*
|
|
83
|
+
* Accepts both `MiddlewareDefinition` from `f.middleware()` and
|
|
84
|
+
* raw `MiddlewareFn` functions.
|
|
85
|
+
*
|
|
86
|
+
* @param mw - Middleware function or MiddlewareDefinition
|
|
83
87
|
* @returns `this` for chaining
|
|
84
88
|
*
|
|
85
89
|
* @example
|
|
@@ -93,7 +97,7 @@ export declare class ActionGroupBuilder<TContext, TCommon extends Record<string,
|
|
|
93
97
|
*
|
|
94
98
|
* @see {@link MiddlewareFn} for the middleware signature
|
|
95
99
|
*/
|
|
96
|
-
use(mw: MiddlewareFn<TContext>): this;
|
|
100
|
+
use(mw: MiddlewareFn<TContext> | MiddlewareDefinition<TContext, Record<string, unknown>>): this;
|
|
97
101
|
/**
|
|
98
102
|
* Omit common schema fields for all actions in this group.
|
|
99
103
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionGroupBuilder.d.ts","sourceRoot":"","sources":["../../../src/core/builder/ActionGroupBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AACvD,OAAO,EACH,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,YAAY,EACpB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionGroupBuilder.d.ts","sourceRoot":"","sources":["../../../src/core/builder/ActionGroupBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AACvD,OAAO,EACH,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,YAAY,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,oCAAoC,CAAC;AAElG;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,iBAAiB,CAAC,QAAQ,EAAE,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC3E,CAAC,KAAK,EA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ared Config → InternalAction Mapper ────────────────
|
|
32
33
|
/**
|
|
33
34
|
* Map `ActionConfig` properties to `InternalAction` base fields.
|
|
@@ -73,7 +74,10 @@ export class ActionGroupBuilder {
|
|
|
73
74
|
* Unlike {@link GroupedToolBuilder.use}, this middleware runs
|
|
74
75
|
* only for actions within this group — not globally.
|
|
75
76
|
*
|
|
76
|
-
*
|
|
77
|
+
* Accepts both `MiddlewareDefinition` from `f.middleware()` and
|
|
78
|
+
* raw `MiddlewareFn` functions.
|
|
79
|
+
*
|
|
80
|
+
* @param mw - Middleware function or MiddlewareDefinition
|
|
77
81
|
* @returns `this` for chaining
|
|
78
82
|
*
|
|
79
83
|
* @example
|
|
@@ -88,7 +92,7 @@ export class ActionGroupBuilder {
|
|
|
88
92
|
* @see {@link MiddlewareFn} for the middleware signature
|
|
89
93
|
*/
|
|
90
94
|
use(mw) {
|
|
91
|
-
this._groupMiddlewares.push(mw);
|
|
95
|
+
this._groupMiddlewares.push(resolveMiddleware(mw));
|
|
92
96
|
return this;
|
|
93
97
|
}
|
|
94
98
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionGroupBuilder.js","sourceRoot":"","sources":["../../../src/core/builder/ActionGroupBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAoC,MAAM,KAAK,CAAC;AACvD,OAAO,EAKN,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionGroupBuilder.js","sourceRoot":"","sources":["../../../src/core/builder/ActionGroupBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAoC,MAAM,KAAK,CAAC;AACvD,OAAO,EAKN,MAAM,aAAa,CAAC;AACrB,OAAO,EAA6B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAsBlG,4DAA4D;AAE5D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,u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,UAAU,CAAC;YAC9C,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC;gBAC1C,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS;SAChD,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* @module
|
|
28
28
|
*/
|
|
29
29
|
import { type MiddlewareFn } from '../types.js';
|
|
30
|
+
import { type MiddlewareDefinition } from '../middleware/ContextDerivation.js';
|
|
30
31
|
import { FluentToolBuilder } from './FluentToolBuilder.js';
|
|
31
32
|
/**
|
|
32
33
|
* Fluent router that shares prefix, description, and middleware
|
|
@@ -50,10 +51,13 @@ export declare class FluentRouter<TContext> {
|
|
|
50
51
|
/**
|
|
51
52
|
* Add middleware shared by all tools in this router.
|
|
52
53
|
*
|
|
53
|
-
*
|
|
54
|
+
* Accepts both `MiddlewareDefinition` from `f.middleware()` and
|
|
55
|
+
* raw `MiddlewareFn` functions.
|
|
56
|
+
*
|
|
57
|
+
* @param mw - Middleware function or MiddlewareDefinition
|
|
54
58
|
* @returns `this` for chaining
|
|
55
59
|
*/
|
|
56
|
-
use(mw: MiddlewareFn<TContext>): this;
|
|
60
|
+
use(mw: MiddlewareFn<TContext> | MiddlewareDefinition<TContext, Record<string, unknown>>): this;
|
|
57
61
|
/**
|
|
58
62
|
* Set capability tags shared by all tools in this router.
|
|
59
63
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FluentRouter.d.ts","sourceRoot":"","sources":["../../../src/core/builder/FluentRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACH,iBAAiB,EAIpB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,qBAAa,YA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AAI,EAAE,MAAM,EAAE,GAAG,IAAI;IAK7B;;;;;OAKG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC;IAIlD;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC;IAIrD;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC;IAInD;;;OAGG;IACH,OAAO,CAAC,cAAc;CAwBzB"}
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* @module
|
|
28
28
|
*/
|
|
29
29
|
import {} from '../types.js';
|
|
30
|
+
import { resolveMiddleware } from '../middleware/ContextDerivation.js';
|
|
30
31
|
import { FluentToolBuilder, QUERY_DEFAULTS, MUTATION_DEFAULTS, ACTION_DEFAULTS, } from './FluentToolBuilder.js';
|
|
31
32
|
/**
|
|
32
33
|
* Fluent router that shares prefix, description, and middleware
|
|
@@ -55,11 +56,14 @@ export class FluentRouter {
|
|
|
55
56
|
/**
|
|
56
57
|
* Add middleware shared by all tools in this router.
|
|
57
58
|
*
|
|
58
|
-
*
|
|
59
|
+
* Accepts both `MiddlewareDefinition` from `f.middleware()` and
|
|
60
|
+
* raw `MiddlewareFn` functions.
|
|
61
|
+
*
|
|
62
|
+
* @param mw - Middleware function or MiddlewareDefinition
|
|
59
63
|
* @returns `this` for chaining
|
|
60
64
|
*/
|
|
61
65
|
use(mw) {
|
|
62
|
-
this._middlewares.push(mw);
|
|
66
|
+
this._middlewares.push(resolveMiddleware(mw));
|
|
63
67
|
return this;
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FluentRouter.js","sourceRoot":"","sources":["../../../src/core/builder/FluentRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAqB,MAAM,aAAa,C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