adonis-mcp-docs 0.1.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 +209 -0
- package/build/.env +6 -0
- package/build/ace.js +7 -0
- package/build/adonisrc.js +34 -0
- package/build/adonisrc.js.map +1 -0
- package/build/app/exceptions/handler.js +13 -0
- package/build/app/exceptions/handler.js.map +1 -0
- package/build/app/mcp/prompts/explain_feature_prompt.js +73 -0
- package/build/app/mcp/prompts/explain_feature_prompt.js.map +1 -0
- package/build/app/mcp/resources/markdown_resource.js +26 -0
- package/build/app/mcp/resources/markdown_resource.js.map +1 -0
- package/build/app/mcp/tools/extract_code_examples_tool.js +80 -0
- package/build/app/mcp/tools/extract_code_examples_tool.js.map +1 -0
- package/build/app/mcp/tools/list_documentation_tool.js +59 -0
- package/build/app/mcp/tools/list_documentation_tool.js.map +1 -0
- package/build/app/mcp/tools/search_in_docs_tool.js +96 -0
- package/build/app/mcp/tools/search_in_docs_tool.js.map +1 -0
- package/build/app/middleware/container_bindings_middleware.js +10 -0
- package/build/app/middleware/container_bindings_middleware.js.map +1 -0
- package/build/app/middleware/mcp_middleware.js +22 -0
- package/build/app/middleware/mcp_middleware.js.map +1 -0
- package/build/app/services/documentation_service.js +48 -0
- package/build/app/services/documentation_service.js.map +1 -0
- package/build/app/services/resource_completion_service.js +11 -0
- package/build/app/services/resource_completion_service.js.map +1 -0
- package/build/bin/console.js +24 -0
- package/build/bin/console.js.map +1 -0
- package/build/bin/mcp.js +25 -0
- package/build/bin/mcp.js.map +1 -0
- package/build/bin/server.js +24 -0
- package/build/bin/server.js.map +1 -0
- package/build/bin/test.js +38 -0
- package/build/bin/test.js.map +1 -0
- package/build/config/app.js +19 -0
- package/build/config/app.js.map +1 -0
- package/build/config/bodyparser.js +26 -0
- package/build/config/bodyparser.js.map +1 -0
- package/build/config/hash.js +14 -0
- package/build/config/hash.js.map +1 -0
- package/build/config/logger.js +21 -0
- package/build/config/logger.js.map +1 -0
- package/build/config/mcp.js +13 -0
- package/build/config/mcp.js.map +1 -0
- package/build/package-lock.json +6705 -0
- package/build/package.json +90 -0
- package/build/start/env.js +9 -0
- package/build/start/env.js.map +1 -0
- package/build/start/kernel.js +7 -0
- package/build/start/kernel.js.map +1 -0
- package/build/start/routes.js +3 -0
- package/build/start/routes.js.map +1 -0
- package/build/tests/bootstrap.js +15 -0
- package/build/tests/bootstrap.js.map +1 -0
- package/package.json +90 -0
package/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Adonis MCP Documentation Server
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server to access adonis-mcp documentation.
|
|
4
|
+
|
|
5
|
+
## 📋 Resources
|
|
6
|
+
|
|
7
|
+
### `file:///{name}.md` - Documentation Markdown File
|
|
8
|
+
Resource template to retrieve markdown documentation files from the GitHub repository.
|
|
9
|
+
|
|
10
|
+
**Available files:**
|
|
11
|
+
- `inspector` - MCP Inspector tool documentation
|
|
12
|
+
- `installation` - Installation guide
|
|
13
|
+
- `introduction` - Introduction to MCP
|
|
14
|
+
- `prompts` - Prompts documentation
|
|
15
|
+
- `resources` - Resources documentation
|
|
16
|
+
- `sessions` - Session management
|
|
17
|
+
- `tools` - Tools documentation
|
|
18
|
+
- `unit-tests` - Unit testing
|
|
19
|
+
|
|
20
|
+
**Usage example:**
|
|
21
|
+
```
|
|
22
|
+
file:///resources.md
|
|
23
|
+
file:///tools.md
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 🛠️ Tools
|
|
27
|
+
|
|
28
|
+
### 1. `list_documentation`
|
|
29
|
+
Lists all available documentation files with their descriptions.
|
|
30
|
+
|
|
31
|
+
**Parameters:** None
|
|
32
|
+
|
|
33
|
+
**Returns:** Structured list of all available documentation files
|
|
34
|
+
|
|
35
|
+
**Annotations:**
|
|
36
|
+
- `@isReadOnly()` - Read-only
|
|
37
|
+
- `@isIdempotent()` - Can be called multiple times without side effects
|
|
38
|
+
|
|
39
|
+
### 2. `search_in_docs`
|
|
40
|
+
Search for a keyword or phrase across all documentation files.
|
|
41
|
+
|
|
42
|
+
**Parameters:**
|
|
43
|
+
- `query` (string, required) - The keyword or phrase to search for
|
|
44
|
+
- `caseSensitive` (boolean, optional) - Case-sensitive search (default: false)
|
|
45
|
+
|
|
46
|
+
**Returns:** List of matches with context (2 lines before/after)
|
|
47
|
+
|
|
48
|
+
**Annotations:**
|
|
49
|
+
- `@isReadOnly()` - Read-only
|
|
50
|
+
- `@isOpenWorld()` - Accesses external resources (GitHub)
|
|
51
|
+
- `@isIdempotent()` - Can be called multiple times without side effects
|
|
52
|
+
|
|
53
|
+
**Example:**
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"query": "Resource templates",
|
|
57
|
+
"caseSensitive": false
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. `extract_code_examples`
|
|
62
|
+
Extracts all code blocks from a documentation file with their languages and line numbers.
|
|
63
|
+
|
|
64
|
+
**Parameters:**
|
|
65
|
+
- `filename` (string, required) - File name (without .md extension)
|
|
66
|
+
|
|
67
|
+
**Returns:** Structured list of all code blocks with their language, content, and line number
|
|
68
|
+
|
|
69
|
+
**Annotations:**
|
|
70
|
+
- `@isReadOnly()` - Read-only
|
|
71
|
+
- `@isOpenWorld()` - Accesses external resources (GitHub)
|
|
72
|
+
- `@isIdempotent()` - Can be called multiple times without side effects
|
|
73
|
+
|
|
74
|
+
**Example:**
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"filename": "resources"
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 🎯 Prompts
|
|
82
|
+
|
|
83
|
+
### `explain_feature`
|
|
84
|
+
Guide to get a detailed explanation of an adonis-mcp feature with code examples.
|
|
85
|
+
|
|
86
|
+
**Parameters:**
|
|
87
|
+
- `feature` (string, required) - The feature to explain
|
|
88
|
+
- `level` (string, optional) - Audience level: "beginner", "intermediate", "advanced" (default: "intermediate")
|
|
89
|
+
|
|
90
|
+
**Suggested features:**
|
|
91
|
+
- resources
|
|
92
|
+
- tools
|
|
93
|
+
- prompts
|
|
94
|
+
- resource templates
|
|
95
|
+
- tool annotations
|
|
96
|
+
- completions
|
|
97
|
+
- authentication
|
|
98
|
+
- authorization
|
|
99
|
+
- sessions
|
|
100
|
+
- unit testing
|
|
101
|
+
- inspector
|
|
102
|
+
- middleware
|
|
103
|
+
|
|
104
|
+
**Example:**
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"feature": "resource templates",
|
|
108
|
+
"level": "intermediate"
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 🚀 Usage
|
|
113
|
+
|
|
114
|
+
### Installation
|
|
115
|
+
|
|
116
|
+
Install globally via npm:
|
|
117
|
+
```bash
|
|
118
|
+
npm install -g adonis-mcp-docs
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Or use with npx (no installation required):
|
|
122
|
+
```bash
|
|
123
|
+
npx adonis-mcp-docs
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Testing locally before publishing
|
|
127
|
+
|
|
128
|
+
1. Build the project:
|
|
129
|
+
```bash
|
|
130
|
+
npm run build
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
2. Test with npx locally:
|
|
134
|
+
```bash
|
|
135
|
+
cd build
|
|
136
|
+
node bin/mcp.js
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Start the MCP server
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
adonis-mcp-docs
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Or with npx:
|
|
146
|
+
```bash
|
|
147
|
+
npx adonis-mcp-docs
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Configuration for MCP Clients
|
|
151
|
+
|
|
152
|
+
Add to your Claude Desktop or Cursor MCP configuration:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"mcpServers": {
|
|
157
|
+
"adonis-mcp-docs": {
|
|
158
|
+
"command": "npx",
|
|
159
|
+
"args": ["adonis-mcp-docs"]
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## 📦 Services
|
|
166
|
+
|
|
167
|
+
### `DocumentationService`
|
|
168
|
+
Manages retrieval of remote markdown files from GitHub.
|
|
169
|
+
|
|
170
|
+
**Methods:**
|
|
171
|
+
- `fetchMarkdownFile(name: string)` - Fetches a markdown file
|
|
172
|
+
- `fileExists(name: string)` - Checks if a file exists
|
|
173
|
+
- `getFileSize(name: string)` - Gets the size of a file
|
|
174
|
+
|
|
175
|
+
### `ResourceCompletionService`
|
|
176
|
+
Provides completion suggestions for documentation file names.
|
|
177
|
+
|
|
178
|
+
**Methods:**
|
|
179
|
+
- `getCompletions(prefix?: string)` - Returns files matching the prefix
|
|
180
|
+
- `getAllNames()` - Returns all available file names
|
|
181
|
+
|
|
182
|
+
## 🔍 Combined Usage Examples
|
|
183
|
+
|
|
184
|
+
### Search then read
|
|
185
|
+
1. Use `search_in_docs` to find where a concept is documented
|
|
186
|
+
2. Use the `file:///{name}.md` resource to read the complete content
|
|
187
|
+
|
|
188
|
+
### Extract and analyze
|
|
189
|
+
1. Use `extract_code_examples` to get all examples
|
|
190
|
+
2. Analyze the code with a custom prompt
|
|
191
|
+
|
|
192
|
+
### Explore then explain
|
|
193
|
+
1. Use `list_documentation` to see what's available
|
|
194
|
+
2. Use the `explain_feature` prompt to get a detailed explanation
|
|
195
|
+
|
|
196
|
+
## 📝 Technical Notes
|
|
197
|
+
|
|
198
|
+
- **Base URL:** `https://raw.githubusercontent.com/batosai/adonis-mcp/main/docs`
|
|
199
|
+
- **Format:** Markdown (`.md`)
|
|
200
|
+
- **Search:** Case-insensitive by default with 2 lines of context
|
|
201
|
+
- **Parsing:** Code block extraction with automatic language detection
|
|
202
|
+
|
|
203
|
+
## 🎨 Advanced Features
|
|
204
|
+
|
|
205
|
+
- ✅ Completions enabled for all templates
|
|
206
|
+
- ✅ Tool annotations to guide AI
|
|
207
|
+
- ✅ Robust error handling
|
|
208
|
+
- ✅ Search with context
|
|
209
|
+
- ✅ Automatic extraction of all code blocks with language detection
|
package/build/.env
ADDED
package/build/ace.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineConfig } from '@adonisjs/core/app';
|
|
2
|
+
export default defineConfig({
|
|
3
|
+
experimental: {
|
|
4
|
+
mergeMultipartFieldsAndFiles: true,
|
|
5
|
+
shutdownInReverseOrder: true,
|
|
6
|
+
},
|
|
7
|
+
commands: [() => import('@adonisjs/core/commands'), () => import('@jrmc/adonis-mcp/commands')],
|
|
8
|
+
providers: [
|
|
9
|
+
() => import('@adonisjs/core/providers/app_provider'),
|
|
10
|
+
() => import('@adonisjs/core/providers/hash_provider'),
|
|
11
|
+
{
|
|
12
|
+
file: () => import('@adonisjs/core/providers/repl_provider'),
|
|
13
|
+
environment: ['repl', 'test'],
|
|
14
|
+
},
|
|
15
|
+
() => import('@jrmc/adonis-mcp/mcp_provider')
|
|
16
|
+
],
|
|
17
|
+
preloads: [() => import('#start/routes'), () => import('#start/kernel')],
|
|
18
|
+
tests: {
|
|
19
|
+
suites: [
|
|
20
|
+
{
|
|
21
|
+
files: ['tests/unit/**/*.spec(.ts|.js)'],
|
|
22
|
+
name: 'unit',
|
|
23
|
+
timeout: 2000,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
files: ['tests/functional/**/*.spec(.ts|.js)'],
|
|
27
|
+
name: 'functional',
|
|
28
|
+
timeout: 30000,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
forceExit: false,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=adonisrc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adonisrc.js","sourceRoot":"","sources":["../adonisrc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,eAAe,YAAY,CAAC;IAW1B,YAAY,EAAE;QACZ,4BAA4B,EAAE,IAAI;QAClC,sBAAsB,EAAE,IAAI;KAC7B;IAWD,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,yBAAyB,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC;IAW9F,SAAS,EAAE;QACT,GAAG,EAAE,CAAC,MAAM,CAAC,uCAAuC,CAAC;QACrD,GAAG,EAAE,CAAC,MAAM,CAAC,wCAAwC,CAAC;QACtD;YACE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,wCAAwC,CAAC;YAC5D,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;SAC9B;QACD,GAAG,EAAE,CAAC,MAAM,CAAC,+BAA+B,CAAC;KAC9C;IAUD,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAWxE,KAAK,EAAE;QACL,MAAM,EAAE;YACN;gBACE,KAAK,EAAE,CAAC,+BAA+B,CAAC;gBACxC,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,IAAI;aACd;YACD;gBACE,KAAK,EAAE,CAAC,qCAAqC,CAAC;gBAC9C,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,KAAK;aACf;SACF;QACD,SAAS,EAAE,KAAK;KACjB;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import app from '@adonisjs/core/services/app';
|
|
2
|
+
import { ExceptionHandler } from '@adonisjs/core/http';
|
|
3
|
+
export default class HttpExceptionHandler extends ExceptionHandler {
|
|
4
|
+
debug = !app.inProduction;
|
|
5
|
+
renderStatusPages = app.inProduction;
|
|
6
|
+
async handle(error, ctx) {
|
|
7
|
+
return super.handle(error, ctx);
|
|
8
|
+
}
|
|
9
|
+
async report(error, ctx) {
|
|
10
|
+
return super.report(error, ctx);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../app/exceptions/handler.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,6BAA6B,CAAA;AAC7C,OAAO,EAAe,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEnE,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,gBAAgB;IAKtD,KAAK,GAAG,CAAC,GAAG,CAAC,YAAY,CAAA;IAOzB,iBAAiB,GAAG,GAAG,CAAC,YAAY,CAAA;IAM9C,KAAK,CAAC,MAAM,CAAC,KAAc,EAAE,GAAgB;QAC3C,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACjC,CAAC;IAQD,KAAK,CAAC,MAAM,CAAC,KAAc,EAAE,GAAgB;QAC3C,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Prompt } from '@jrmc/adonis-mcp';
|
|
2
|
+
export default class ExplainFeaturePrompt extends Prompt {
|
|
3
|
+
name = 'explain_feature';
|
|
4
|
+
title = 'Explain Documentation Feature';
|
|
5
|
+
description = 'Get a detailed explanation of an adonis-mcp feature with code examples and best practices';
|
|
6
|
+
async handle({ args, response }) {
|
|
7
|
+
const feature = args?.feature;
|
|
8
|
+
const level = args?.level || 'intermediate';
|
|
9
|
+
return [
|
|
10
|
+
response.text(`Please explain the "${feature}" feature in adonis-mcp in detail.`),
|
|
11
|
+
response.text(`Target audience level: ${level}`),
|
|
12
|
+
response.text(''),
|
|
13
|
+
response.text('Include the following in your explanation:'),
|
|
14
|
+
response.text('1. **Overview**: What is this feature and why is it useful?'),
|
|
15
|
+
response.text('2. **How it works**: Explain the core concepts and mechanics'),
|
|
16
|
+
response.text('3. **Code Examples**: Provide practical, working code examples'),
|
|
17
|
+
response.text('4. **Common Use Cases**: When and why to use this feature'),
|
|
18
|
+
response.text('5. **Best Practices**: Tips for effective implementation'),
|
|
19
|
+
response.text('6. **Common Pitfalls**: What to avoid and potential issues'),
|
|
20
|
+
response.text('7. **Related Features**: Other features that work well with this'),
|
|
21
|
+
response.text(''),
|
|
22
|
+
response.embeddedResource('file:///resources.md'),
|
|
23
|
+
response.embeddedResource('file:///tools.md'),
|
|
24
|
+
response.embeddedResource('file:///prompts.md'),
|
|
25
|
+
response.text(''),
|
|
26
|
+
response.text('Use the embedded documentation resources above as reference.')
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
async complete({ args, response }) {
|
|
30
|
+
const typedArgs = args;
|
|
31
|
+
if (typedArgs?.feature !== undefined) {
|
|
32
|
+
return response.complete({
|
|
33
|
+
values: [
|
|
34
|
+
'resources',
|
|
35
|
+
'tools',
|
|
36
|
+
'prompts',
|
|
37
|
+
'resource templates',
|
|
38
|
+
'tool annotations',
|
|
39
|
+
'completions',
|
|
40
|
+
'authentication',
|
|
41
|
+
'authorization',
|
|
42
|
+
'sessions',
|
|
43
|
+
'unit testing',
|
|
44
|
+
'inspector',
|
|
45
|
+
'middleware'
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (typedArgs?.level !== undefined) {
|
|
50
|
+
return response.complete({
|
|
51
|
+
values: ['beginner', 'intermediate', 'advanced']
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return response.complete({ values: [] });
|
|
55
|
+
}
|
|
56
|
+
schema() {
|
|
57
|
+
return {
|
|
58
|
+
type: 'object',
|
|
59
|
+
properties: {
|
|
60
|
+
feature: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'The feature or concept to explain (e.g., "resources", "tools", "prompts", "authentication")'
|
|
63
|
+
},
|
|
64
|
+
level: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'Target audience level: beginner, intermediate, or advanced (default: intermediate)'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
required: ['feature']
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=explain_feature_prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain_feature_prompt.js","sourceRoot":"","sources":["../../../../app/mcp/prompts/explain_feature_prompt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAUzC,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,MAAc;IAC9D,IAAI,GAAG,iBAAiB,CAAA;IACxB,KAAK,GAAG,+BAA+B,CAAA;IACvC,WAAW,GAAG,2FAA2F,CAAA;IAEzG,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAyB;QACpD,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,CAAA;QAC7B,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,cAAc,CAAA;QAE3C,OAAO;YACL,QAAQ,CAAC,IAAI,CAAC,uBAAuB,OAAO,oCAAoC,CAAC;YACjF,QAAQ,CAAC,IAAI,CAAC,0BAA0B,KAAK,EAAE,CAAC;YAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACjB,QAAQ,CAAC,IAAI,CAAC,4CAA4C,CAAC;YAC3D,QAAQ,CAAC,IAAI,CAAC,6DAA6D,CAAC;YAC5E,QAAQ,CAAC,IAAI,CAAC,8DAA8D,CAAC;YAC7E,QAAQ,CAAC,IAAI,CAAC,gEAAgE,CAAC;YAC/E,QAAQ,CAAC,IAAI,CAAC,2DAA2D,CAAC;YAC1E,QAAQ,CAAC,IAAI,CAAC,0DAA0D,CAAC;YACzE,QAAQ,CAAC,IAAI,CAAC,4DAA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W,EAAE,oFAAoF;iBAClG;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACZ,CAAA;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Resource } from '@jrmc/adonis-mcp';
|
|
2
|
+
import { DocumentationService } from '#services/documentation_service';
|
|
3
|
+
import { ResourceCompletionService } from '#services/resource_completion_service';
|
|
4
|
+
export default class MarkdownResource extends Resource {
|
|
5
|
+
name = 'documentation_file';
|
|
6
|
+
uri = 'file:///{name}.md';
|
|
7
|
+
mimeType = 'text/markdown';
|
|
8
|
+
title = 'Documentation Markdown File';
|
|
9
|
+
description = 'Dynamic resource to access markdown documentation files. Use {name} parameter to specify the file to retrieve.';
|
|
10
|
+
async handle({ args, response }) {
|
|
11
|
+
const documentationService = new DocumentationService();
|
|
12
|
+
const name = args?.name;
|
|
13
|
+
if (!name) {
|
|
14
|
+
throw new Error('File name is required');
|
|
15
|
+
}
|
|
16
|
+
const content = await documentationService.fetchMarkdownFile(name);
|
|
17
|
+
this.size = content.length;
|
|
18
|
+
return response.text(content);
|
|
19
|
+
}
|
|
20
|
+
async complete({ args, response }) {
|
|
21
|
+
const resourceCompletionService = new ResourceCompletionService();
|
|
22
|
+
const completions = resourceCompletionService.getCompletions(args?.name);
|
|
23
|
+
return response.complete({ values: completions });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=markdown_resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown_resource.js","sourceRoot":"","sources":["../../../../app/mcp/resources/markdown_resource.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AAMjF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,QAAc;IAC1D,IAAI,GAAG,oBAAoB,CAAA;IAC3B,GAAG,GAAG,mBAAmB,CAAA;IACzB,QAAQ,GAAG,eAAe,CAAA;IAE1B,KAAK,GAAG,6BAA6B,CAAA;IACrC,WAAW,GAAG,gHAAgH,CAAA;IAE9H,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAyB;QACpD,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAA;QACvD,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI,CAAA;QAEvB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;QAC1C,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;QAClE,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAA;QAE1B,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAyB;QACtD,MAAM,yBAAyB,GAAG,IAAI,yBAAyB,EAAE,CAAA;QACjE,MAAM,WAAW,GAAG,yBAAyB,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACxE,OAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAA;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Tool } from '@jrmc/adonis-mcp';
|
|
8
|
+
import { isReadOnly, isOpenWorld, isIdempotent } from '@jrmc/adonis-mcp/tool_annotations';
|
|
9
|
+
import { DocumentationService } from '#services/documentation_service';
|
|
10
|
+
let ExtractCodeExamplesTool = class ExtractCodeExamplesTool extends Tool {
|
|
11
|
+
name = 'extract_code_examples';
|
|
12
|
+
title = 'Extract Code Examples';
|
|
13
|
+
description = 'Extracts all code blocks from a documentation file with their language and line numbers';
|
|
14
|
+
async handle({ args, response }) {
|
|
15
|
+
const typedArgs = args;
|
|
16
|
+
const filename = typedArgs?.filename;
|
|
17
|
+
if (!filename || filename.trim() === '') {
|
|
18
|
+
return response.error('Filename is required');
|
|
19
|
+
}
|
|
20
|
+
const documentationService = new DocumentationService();
|
|
21
|
+
try {
|
|
22
|
+
const content = await documentationService.fetchMarkdownFile(filename);
|
|
23
|
+
const codeBlocks = [];
|
|
24
|
+
const lines = content.split('\n');
|
|
25
|
+
for (let i = 0; i < lines.length; i++) {
|
|
26
|
+
const line = lines[i];
|
|
27
|
+
const blockStart = line.match(/^```(\w+)?$/);
|
|
28
|
+
if (blockStart) {
|
|
29
|
+
const blockLanguage = blockStart[1] || 'text';
|
|
30
|
+
const codeLines = [];
|
|
31
|
+
let j = i + 1;
|
|
32
|
+
while (j < lines.length && !lines[j].match(/^```$/)) {
|
|
33
|
+
codeLines.push(lines[j]);
|
|
34
|
+
j++;
|
|
35
|
+
}
|
|
36
|
+
if (j < lines.length) {
|
|
37
|
+
codeBlocks.push({
|
|
38
|
+
language: blockLanguage,
|
|
39
|
+
code: codeLines.join('\n'),
|
|
40
|
+
lineNumber: i + 1
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (codeBlocks.length === 0) {
|
|
46
|
+
return response.text(`No code blocks found in '${filename}'`);
|
|
47
|
+
}
|
|
48
|
+
return response.structured({
|
|
49
|
+
filename: filename,
|
|
50
|
+
totalBlocks: codeBlocks.length,
|
|
51
|
+
codeBlocks: codeBlocks
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error instanceof Error) {
|
|
56
|
+
return response.error(`Failed to extract code examples: ${error.message}`);
|
|
57
|
+
}
|
|
58
|
+
return response.error('Failed to extract code examples from documentation');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
schema() {
|
|
62
|
+
return {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
filename: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: 'Name of the documentation file (without .md extension, e.g., "resources", "tools")'
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
required: ['filename']
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
ExtractCodeExamplesTool = __decorate([
|
|
75
|
+
isReadOnly(),
|
|
76
|
+
isOpenWorld(),
|
|
77
|
+
isIdempotent()
|
|
78
|
+
], ExtractCodeExamplesTool);
|
|
79
|
+
export default ExtractCodeExamplesTool;
|
|
80
|
+
//# sourceMappingURL=extract_code_examples_tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract_code_examples_tool.js","sourceRoot":"","sources":["../../../../app/mcp/tools/extract_code_examples_tool.ts"],"names":[],"mappings":";;;;;;AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAYvD,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,IAAY;IAC/D,IAAI,GAAG,uBAAuB,CAAA;IAC9B,KAAK,GAAG,uBAAuB,CAAA;IAC/B,W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 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Tool } from '@jrmc/adonis-mcp';
|
|
8
|
+
import { isReadOnly, isIdempotent } from '@jrmc/adonis-mcp/tool_annotations';
|
|
9
|
+
let ListDocumentationTool = class ListDocumentationTool extends Tool {
|
|
10
|
+
name = 'list_documentation';
|
|
11
|
+
title = 'List Documentation Files';
|
|
12
|
+
description = 'Lists all available documentation markdown files with their names and descriptions';
|
|
13
|
+
async handle({ response }) {
|
|
14
|
+
const documentationFiles = [
|
|
15
|
+
{
|
|
16
|
+
name: 'inspector',
|
|
17
|
+
description: 'Documentation about the MCP Inspector tool for debugging and testing'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'installation',
|
|
21
|
+
description: 'Installation guide for setting up adonis-mcp in your project'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'introduction',
|
|
25
|
+
description: 'Introduction to the Model Context Protocol (MCP) and adonis-mcp'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'prompts',
|
|
29
|
+
description: 'Guide on creating and using prompts in your MCP server'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'resources',
|
|
33
|
+
description: 'Documentation about MCP resources and how to create them'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'sessions',
|
|
37
|
+
description: 'Information about session management in MCP'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'tools',
|
|
41
|
+
description: 'Guide on creating and implementing tools in your MCP server'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'unit-tests',
|
|
45
|
+
description: 'Documentation on writing unit tests for your MCP components'
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
return response.structured({
|
|
49
|
+
total: documentationFiles.length,
|
|
50
|
+
files: documentationFiles
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
ListDocumentationTool = __decorate([
|
|
55
|
+
isReadOnly(),
|
|
56
|
+
isIdempotent()
|
|
57
|
+
], ListDocumentationTool);
|
|
58
|
+
export default ListDocumentationTool;
|
|
59
|
+
//# sourceMappingURL=list_documentation_tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list_documentation_tool.js","sourceRoot":"","sources":["../../../../app/mcp/tools/list_documentation_tool.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAO7D,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,IAAI;IACrD,IAAI,GAAG,oBAAoB,CAAA;IAC3B,KAAK,GAAG,0BAA0B,CAAA;IAClC,WAAW,GAAG,oFAAoF,CAAA;IAElG,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAe;QACpC,MAAM,kBAAkB,GAAG;YACzB;gBACE,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,sEAAsE;aACpF;YACD;gBACE,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE,8DAA8D;aAC5E;YACD;gBACE,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE,iEAAiE;aAC/E;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,wDAAwD;aACtE;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,0DAA0D;aACxE;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,6CAA6C;aAC3D;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,6DAA6D;aAC3E;YACD;gBACE,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,6DAA6D;aAC3E;SACF,CAAA;QAED,OAAO,QAAQ,CAAC,UAAU,CAAC;YACzB,KAAK,EAAE,kBAAkB,CAAC,MAAM;YAChC,KAAK,EAAE,kBAAkB;SAC1B,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA9CoB,qBAAqB;IAFzC,UAAU,EAAE;IACZ,YAAY,EAAE;GACM,qBAAqB,CA8CzC;eA9CoB,qBAAqB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Tool } from '@jrmc/adonis-mcp';
|
|
8
|
+
import { isReadOnly, isOpenWorld, isIdempotent } from '@jrmc/adonis-mcp/tool_annotations';
|
|
9
|
+
import { DocumentationService } from '#services/documentation_service';
|
|
10
|
+
let SearchInDocsTool = class SearchInDocsTool extends Tool {
|
|
11
|
+
name = 'search_in_docs';
|
|
12
|
+
title = 'Search in Documentation';
|
|
13
|
+
description = 'Search for a keyword or phrase across all documentation files and return matching sections';
|
|
14
|
+
async handle({ args, response }) {
|
|
15
|
+
const query = args?.query;
|
|
16
|
+
const caseSensitive = args?.caseSensitive ?? false;
|
|
17
|
+
if (!query || query.trim() === '') {
|
|
18
|
+
return response.error('Search query is required');
|
|
19
|
+
}
|
|
20
|
+
const documentationService = new DocumentationService();
|
|
21
|
+
const fileNames = [
|
|
22
|
+
'inspector',
|
|
23
|
+
'installation',
|
|
24
|
+
'introduction',
|
|
25
|
+
'prompts',
|
|
26
|
+
'resources',
|
|
27
|
+
'sessions',
|
|
28
|
+
'tools',
|
|
29
|
+
'unit-tests'
|
|
30
|
+
];
|
|
31
|
+
const results = [];
|
|
32
|
+
for (const fileName of fileNames) {
|
|
33
|
+
try {
|
|
34
|
+
const content = await documentationService.fetchMarkdownFile(fileName);
|
|
35
|
+
const lines = content.split('\n');
|
|
36
|
+
const matches = [];
|
|
37
|
+
const searchQuery = caseSensitive ? query : query.toLowerCase();
|
|
38
|
+
lines.forEach((line, index) => {
|
|
39
|
+
const searchLine = caseSensitive ? line : line.toLowerCase();
|
|
40
|
+
if (searchLine.includes(searchQuery)) {
|
|
41
|
+
const contextBefore = lines.slice(Math.max(0, index - 2), index);
|
|
42
|
+
const contextAfter = lines.slice(index + 1, Math.min(lines.length, index + 3));
|
|
43
|
+
matches.push({
|
|
44
|
+
lineNumber: index + 1,
|
|
45
|
+
line: line.trim(),
|
|
46
|
+
context: [...contextBefore, ...contextAfter].map(l => l.trim())
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (matches.length > 0) {
|
|
51
|
+
results.push({
|
|
52
|
+
file: fileName,
|
|
53
|
+
matches: matches
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (results.length === 0) {
|
|
62
|
+
return response.text(`No results found for query: "${query}"`);
|
|
63
|
+
}
|
|
64
|
+
const totalMatches = results.reduce((sum, result) => sum + result.matches.length, 0);
|
|
65
|
+
return response.structured({
|
|
66
|
+
query: query,
|
|
67
|
+
caseSensitive: caseSensitive,
|
|
68
|
+
totalFiles: results.length,
|
|
69
|
+
totalMatches: totalMatches,
|
|
70
|
+
results: results
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
schema() {
|
|
74
|
+
return {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
query: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'The search query (keyword or phrase to find in documentation)'
|
|
80
|
+
},
|
|
81
|
+
caseSensitive: {
|
|
82
|
+
type: 'boolean',
|
|
83
|
+
description: 'Whether the search should be case-sensitive (default: false)'
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
required: ['query']
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
SearchInDocsTool = __decorate([
|
|
91
|
+
isReadOnly(),
|
|
92
|
+
isOpenWorld(),
|
|
93
|
+
isIdempotent()
|
|
94
|
+
], SearchInDocsTool);
|
|
95
|
+
export default SearchInDocsTool;
|
|
96
|
+
//# sourceMappingURL=search_in_docs_tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search_in_docs_tool.js","sourceRoot":"","sources":["../../../../app/mcp/tools/search_in_docs_tool.ts"],"names":[],"mappings":";;;;;;AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAavD,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAY;IACxD,IAAI,GAAG,gBAAgB,CAAA;IACvB,KAAK,GAAG,yBAAyB,CAAA;IACjC,WAAW,GAAG,4FAA4F,CAAA;IAE1G,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAuB;QAClD,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,CAAA;QACzB,MAAM,aAAa,GAAG,IAAI,EAAE,aAAa,IAAI,KAAK,CAAA;QAElD,IAAI,CAAC,KAAK,IA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D;iBAC5E;aACF;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;SACV,CAAA;IACb,CAAC;CACF,CAAA;AAlGoB,gBAAgB;IAHpC,UAAU,EAAE;IACZ,WAAW,EAAE;IACb,YAAY,EAAE;GACM,gBAAgB,CAkGpC;eAlGoB,gBAAgB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Logger } from '@adonisjs/core/logger';
|
|
2
|
+
import { HttpContext } from '@adonisjs/core/http';
|
|
3
|
+
export default class ContainerBindingsMiddleware {
|
|
4
|
+
handle(ctx, next) {
|
|
5
|
+
ctx.containerResolver.bindValue(HttpContext, ctx);
|
|
6
|
+
ctx.containerResolver.bindValue(Logger, ctx.logger);
|
|
7
|
+
return next();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=container_bindings_middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container_bindings_middleware.js","sourceRoot":"","sources":["../../../app/middleware/container_bindings_middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAUjD,MAAM,CAAC,OAAO,OAAO,2BAA2B;IAC9C,MAAM,CAAC,GAAgB,EAAE,IAAY;QACnC,GAAG,CAAC,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;QACjD,GAAG,CAAC,iBAAiB,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAEnD,OAAO,IAAI,EAAE,CAAA;IACf,CAAC;CACF"}
|