@jrmc/adonis-mcp 1.0.0-beta.8 → 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/README.md +9 -10
- package/build/commands/commands.json +1 -1
- package/build/commands/inspector.d.ts +1 -0
- package/build/commands/inspector.d.ts.map +1 -1
- package/build/commands/inspector.js +1 -0
- package/build/commands/make/prompt.d.ts.map +1 -1
- package/build/commands/make/prompt.js +4 -1
- package/build/commands/make/tool.d.ts.map +1 -1
- package/build/commands/make/tool.js +4 -1
- package/build/configure.d.ts.map +1 -1
- package/build/configure.js +10 -0
- package/build/providers/mcp_provider.d.ts +5 -0
- package/build/providers/mcp_provider.d.ts.map +1 -1
- package/build/providers/mcp_provider.js +3 -1
- package/build/src/server/mcp_bouncer.d.ts +115 -0
- package/build/src/server/mcp_bouncer.d.ts.map +1 -0
- package/build/src/server/mcp_bouncer.js +123 -0
- package/build/src/server/transports/http_transport.d.ts.map +1 -1
- package/build/src/server/transports/http_transport.js +4 -3
- package/build/src/server.d.ts +7 -1
- package/build/src/server.d.ts.map +1 -1
- package/build/src/server.js +23 -6
- package/build/stubs/make/mcp/prompts/main.ts.stub +1 -1
- package/build/stubs/make/mcp/prompts/with_vine.ts.stub +40 -0
- package/build/stubs/make/mcp/tools/with_vine.ts.stub +37 -0
- package/build/stubs/make/middleware/mcp_middleware.ts.stub +6 -7
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -9
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{{#var className = `${name}Tool`}}
|
|
2
|
+
{{#var toolName = string(name).snakeCase()}}
|
|
3
|
+
{{#var resourceFileName = string(className).snakeCase().ext('.ts').toString()}}
|
|
4
|
+
{{{
|
|
5
|
+
exports({
|
|
6
|
+
to: app.makePath(app.rcFile.directories['mcp'] || 'app/mcp/', `tools/`, resourceFileName)
|
|
7
|
+
})
|
|
8
|
+
}}}
|
|
9
|
+
import type { ToolContext } from '@jrmc/adonis-mcp/types/context'
|
|
10
|
+
import type { BaseSchema } from '@jrmc/adonis-mcp/types/method'
|
|
11
|
+
|
|
12
|
+
import { Tool } from '@jrmc/adonis-mcp'
|
|
13
|
+
import vine from '@vinejs/vine'
|
|
14
|
+
|
|
15
|
+
type Schema = BaseSchema<{
|
|
16
|
+
name: { type: "string" }
|
|
17
|
+
}>
|
|
18
|
+
|
|
19
|
+
const vineSchema = vine.object({
|
|
20
|
+
name: vine.string().meta({
|
|
21
|
+
description: 'Description text argument',
|
|
22
|
+
}),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export default class {{ className }} extends Tool<Schema> {
|
|
26
|
+
name = '{{ toolName }}'
|
|
27
|
+
title = 'Tool title'
|
|
28
|
+
description = 'Tool description'
|
|
29
|
+
|
|
30
|
+
async handle({ args, response }: ToolContext<Schema>) {
|
|
31
|
+
return response.text({{ "`Hello, ${args?.name}`" }})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
schema() {
|
|
35
|
+
return vine.create(vineSchema).toJSONSchema() as Schema
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
}}}
|
|
4
4
|
import type { HttpContext } from '@adonisjs/core/http'
|
|
5
5
|
import type { NextFn } from '@adonisjs/core/types/http'
|
|
6
|
+
// import type * as abilities from '#abilities/main'
|
|
7
|
+
// import type { policies } from '#generated/policies'
|
|
8
|
+
// import type McpBouncer from '@jrmc/adonis-mcp/bouncer'
|
|
6
9
|
|
|
7
10
|
import crypto from 'node:crypto'
|
|
8
11
|
|
|
9
|
-
// import { policies } from '#policies/main'
|
|
10
|
-
// import * as abilities from '#abilities/main'
|
|
11
|
-
// import { Bouncer } from '@adonisjs/bouncer'
|
|
12
|
-
|
|
13
12
|
export default class McpMiddleware {
|
|
14
13
|
async handle(ctx: HttpContext, next: NextFn) {
|
|
15
14
|
const body = ctx.request.body()
|
|
@@ -38,10 +37,10 @@ export default class McpMiddleware {
|
|
|
38
37
|
|
|
39
38
|
// declare module '@jrmc/adonis-mcp/types/context' {
|
|
40
39
|
// export interface McpContext {
|
|
41
|
-
// auth
|
|
42
|
-
// user
|
|
40
|
+
// auth: {
|
|
41
|
+
// user: HttpContext['auth']['user']
|
|
43
42
|
// }
|
|
44
|
-
// bouncer
|
|
43
|
+
// bouncer: McpBouncer<
|
|
45
44
|
// Exclude<HttpContext['auth']['user'], undefined>,
|
|
46
45
|
// typeof abilities,
|
|
47
46
|
// typeof policies
|