@afterxleep/doc-bot 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 docs-mcp-server contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,359 @@
1
+ # docbot
2
+
3
+ [![npm version](https://img.shields.io/npm/v/docbot)](https://www.npmjs.com/package/docbot)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A generic, open-source MCP (Model Context Protocol) server that provides intelligent documentation access for any project. Works with AI agents like Claude Code, Cursor, and any other MCP-compatible tools.
7
+
8
+ ## 🚀 Features
9
+
10
+ - **🔍 Smart Documentation Search**: Full-text search across all documentation
11
+ - **🧠 Intelligent Inference**: Context-aware documentation suggestions based on your current work
12
+ - **📋 Global Rules**: Always-apply documentation that's relevant to every interaction
13
+ - **🎯 Contextual Docs**: File-specific documentation based on patterns and file types
14
+ - **📦 Zero Config**: Works out of the box with a simple `docbot/` folder
15
+ - **🔄 Hot Reload**: Automatically updates when documentation changes
16
+ - **🛠️ Universal**: Works with any project, any language, any framework
17
+
18
+ ## 📦 Installation & Usage
19
+
20
+ ### Quick Start
21
+
22
+ 1. **Install and run in your project:**
23
+ ```bash
24
+ # Navigate to your project directory
25
+ cd your-project
26
+
27
+ # Run the server (installs automatically)
28
+ npx docbot
29
+ ```
30
+
31
+ 2. **Create your documentation structure:**
32
+ ```bash
33
+ mkdir docbot
34
+ echo '{"name": "My Project Documentation", "globalRules": []}' > docbot/manifest.json
35
+ echo "# Getting Started" > docbot/README.md
36
+ ```
37
+
38
+ 3. **Add to your Claude Code configuration:**
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "docs": {
43
+ "command": "npx",
44
+ "args": ["docbot"]
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ 4. **Restart Claude Code and start using intelligent documentation!**
51
+
52
+ ### Global Installation
53
+
54
+ ```bash
55
+ # Install globally
56
+ npm install -g docbot
57
+
58
+ # Run in any project
59
+ docbot
60
+ ```
61
+
62
+ ## 📁 Project Structure
63
+
64
+ Create a `docbot/` folder in your project root:
65
+
66
+ ```
67
+ your-project/
68
+ ├── docbot/
69
+ │ ├── manifest.json # Configuration and rules
70
+ │ ├── core/
71
+ │ │ ├── architecture.md # Always-apply architecture guidelines
72
+ │ │ ├── coding-standards.md # Coding standards for all files
73
+ │ │ └── security.md # Security guidelines
74
+ │ ├── guides/
75
+ │ │ ├── testing.md # Testing strategies
76
+ │ │ ├── deployment.md # Deployment procedures
77
+ │ │ └── api-development.md # API development guide
78
+ │ └── reference/
79
+ │ ├── troubleshooting.md # Common issues and solutions
80
+ │ └── best-practices.md # Best practices by topic
81
+ └── package.json
82
+ ```
83
+
84
+ ## ⚙️ Configuration
85
+
86
+ ### Manifest File (`docbot/manifest.json`)
87
+
88
+ ```json
89
+ {
90
+ "name": "My Project Documentation",
91
+ "version": "1.0.0",
92
+ "description": "AI-powered documentation for My Project",
93
+ "globalRules": [
94
+ "core/coding-standards.md",
95
+ "core/security.md"
96
+ ],
97
+ "contextualRules": {
98
+ "*.test.js": ["guides/testing.md"],
99
+ "*.spec.js": ["guides/testing.md"],
100
+ "src/components/*": ["guides/react-components.md"],
101
+ "src/api/*": ["guides/api-development.md"],
102
+ "*.md": ["guides/documentation.md"],
103
+ "package.json": ["guides/dependencies.md"]
104
+ },
105
+ "inference": {
106
+ "keywords": {
107
+ "testing": ["guides/testing.md"],
108
+ "deployment": ["guides/deployment.md"],
109
+ "api": ["guides/api-development.md"],
110
+ "security": ["core/security.md"],
111
+ "performance": ["guides/performance.md"]
112
+ },
113
+ "patterns": {
114
+ "describe(": ["guides/testing.md"],
115
+ "it(": ["guides/testing.md"],
116
+ "fetch(": ["guides/api-development.md"],
117
+ "console.error": ["reference/troubleshooting.md"],
118
+ "try {": ["reference/error-handling.md"]
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ ### Configuration Options
125
+
126
+ - **`globalRules`**: Documentation that applies to all interactions
127
+ - **`contextualRules`**: Documentation triggered by specific file patterns
128
+ - **`inference.keywords`**: Documentation triggered by keywords in queries
129
+ - **`inference.patterns`**: Documentation triggered by code patterns
130
+
131
+ ## 🔧 CLI Options
132
+
133
+ ```bash
134
+ docbot [options]
135
+
136
+ Options:
137
+ -p, --port <port> Port to run server on (default: 3000)
138
+ -d, --docs <path> Path to docs folder (default: ./docbot)
139
+ -c, --config <path> Path to manifest file (default: ./docbot/manifest.json)
140
+ -v, --verbose Enable verbose logging
141
+ -w, --watch Watch for file changes
142
+ -h, --help Show help
143
+ ```
144
+
145
+ ## 🎯 How It Works
146
+
147
+ ### 1. Global Rules (Always Apply)
148
+ Documents listed in `globalRules` are automatically included in every AI interaction:
149
+
150
+ ```json
151
+ {
152
+ "globalRules": [
153
+ "core/coding-standards.md",
154
+ "core/security.md"
155
+ ]
156
+ }
157
+ ```
158
+
159
+ ### 2. Contextual Rules (File-Based)
160
+ When you're working on specific files, relevant documentation is automatically suggested:
161
+
162
+ ```json
163
+ {
164
+ "contextualRules": {
165
+ "*.test.js": ["guides/testing.md"],
166
+ "src/components/*": ["guides/react-components.md"]
167
+ }
168
+ }
169
+ ```
170
+
171
+ ### 3. Smart Inference
172
+ The server analyzes your queries and code to suggest relevant documentation:
173
+
174
+ - **Keywords**: "testing" → `guides/testing.md`
175
+ - **Code Patterns**: `describe(` → `guides/testing.md`
176
+ - **File Extensions**: `.py` → Python-related docs
177
+
178
+ ## 📖 Documentation Format
179
+
180
+ ### Frontmatter Support
181
+ Add metadata to your documentation:
182
+
183
+ ```markdown
184
+ ---
185
+ title: Testing Guide
186
+ description: Comprehensive testing strategies
187
+ category: guides
188
+ tags: [testing, jest, react]
189
+ alwaysApply: false
190
+ ---
191
+
192
+ # Testing Guide
193
+
194
+ Your documentation content here...
195
+ ```
196
+
197
+ ### Supported Formats
198
+ - **Markdown** (`.md`)
199
+ - **MDX** (`.mdx`)
200
+ - **Cursor Rules** (`.mdc`)
201
+
202
+ ## 🛠️ Available Tools
203
+
204
+ When using with Claude Code or other MCP clients:
205
+
206
+ ### `search_documentation`
207
+ ```javascript
208
+ // Search all documentation
209
+ search_documentation({ query: "testing best practices" })
210
+ ```
211
+
212
+ ### `get_relevant_docs`
213
+ ```javascript
214
+ // Get context-aware suggestions
215
+ get_relevant_docs({
216
+ context: {
217
+ query: "How to test React components",
218
+ filePath: "src/components/UserProfile.test.tsx",
219
+ codeSnippet: "describe('UserProfile', () => {"
220
+ }
221
+ })
222
+ ```
223
+
224
+ ### `get_global_rules`
225
+ ```javascript
226
+ // Get always-apply documentation
227
+ get_global_rules()
228
+ ```
229
+
230
+ ### `get_file_docs`
231
+ ```javascript
232
+ // Get file-specific documentation
233
+ get_file_docs({ filePath: "src/api/users.js" })
234
+ ```
235
+
236
+ ## 🌟 Examples
237
+
238
+ ### React Project
239
+ ```json
240
+ {
241
+ "globalRules": ["core/react-standards.md"],
242
+ "contextualRules": {
243
+ "src/components/*": ["guides/components.md"],
244
+ "*.test.tsx": ["guides/testing.md"]
245
+ },
246
+ "inference": {
247
+ "keywords": {
248
+ "hook": ["guides/hooks.md"],
249
+ "state": ["guides/state-management.md"]
250
+ },
251
+ "patterns": {
252
+ "useState": ["guides/hooks.md"],
253
+ "useEffect": ["guides/hooks.md"]
254
+ }
255
+ }
256
+ }
257
+ ```
258
+
259
+ ### Node.js API Project
260
+ ```json
261
+ {
262
+ "globalRules": ["core/api-standards.md", "core/security.md"],
263
+ "contextualRules": {
264
+ "routes/*": ["guides/routing.md"],
265
+ "middleware/*": ["guides/middleware.md"],
266
+ "*.test.js": ["guides/testing.md"]
267
+ },
268
+ "inference": {
269
+ "keywords": {
270
+ "authentication": ["guides/auth.md"],
271
+ "database": ["guides/database.md"]
272
+ },
273
+ "patterns": {
274
+ "app.get": ["guides/routing.md"],
275
+ "app.post": ["guides/routing.md"]
276
+ }
277
+ }
278
+ }
279
+ ```
280
+
281
+ ## 🔄 Integration with IDEs
282
+
283
+ ### Claude Code
284
+ 1. Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
285
+ ```json
286
+ {
287
+ "mcpServers": {
288
+ "docs": {
289
+ "command": "npx",
290
+ "args": ["docbot"]
291
+ }
292
+ }
293
+ }
294
+ ```
295
+
296
+ ### Cursor
297
+ Configure MCP server integration (coming soon)
298
+
299
+ ### VS Code
300
+ Use with Claude Code extension or MCP-compatible extensions
301
+
302
+ ## 🧪 Testing Your Setup
303
+
304
+ 1. **Create test documentation:**
305
+ ```bash
306
+ mkdir docbot
307
+ echo '{"name": "Test Docs", "globalRules": ["test.md"]}' > docbot/manifest.json
308
+ echo "# Test Document\nThis is a test." > docbot/test.md
309
+ ```
310
+
311
+ 2. **Run the server:**
312
+ ```bash
313
+ npx docbot --verbose
314
+ ```
315
+
316
+ 3. **Test with Claude Code:**
317
+ - Ask: "What documentation is available?"
318
+ - Try: "Show me the global rules"
319
+
320
+ ## 🤝 Contributing
321
+
322
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
323
+
324
+ ### Development Setup
325
+ ```bash
326
+ # Clone the repository
327
+ git clone https://github.com/yourusername/docbot.git
328
+ cd docbot
329
+
330
+ # Install dependencies
331
+ npm install
332
+
333
+ # Run tests
334
+ npm test
335
+
336
+ # Run in development mode
337
+ npm run dev
338
+ ```
339
+
340
+ ## 📄 License
341
+
342
+ MIT License - see the [LICENSE](LICENSE) file for details.
343
+
344
+ ## 🙏 Acknowledgments
345
+
346
+ - Built on the [Model Context Protocol](https://github.com/modelcontextprotocol/specification)
347
+ - Inspired by the need for intelligent, context-aware documentation
348
+ - Thanks to the Claude Code and Cursor teams for MCP support
349
+
350
+ ## 🔗 Links
351
+
352
+ - [npm package](https://www.npmjs.com/package/docbot)
353
+ - [GitHub repository](https://github.com/yourusername/docbot)
354
+ - [Model Context Protocol](https://github.com/modelcontextprotocol/specification)
355
+ - [Claude Code documentation](https://docs.anthropic.com/claude/docs/claude-code)
356
+
357
+ ---
358
+
359
+ **Made with ❤️ for developers who want intelligent documentation at their fingertips.**
package/bin/doc-bot.js ADDED
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { program } = require('commander');
4
+ const path = require('path');
5
+ const fs = require('fs-extra');
6
+ const { DocsServer } = require('../src/index.js');
7
+
8
+ program
9
+ .name('doc-bot')
10
+ .description('Generic MCP server for intelligent documentation access')
11
+ .version('1.0.0')
12
+ .option('-p, --port <port>', 'Port to run server on', '3000')
13
+ .option('-d, --docs <path>', 'Path to docs folder', './docs.ai')
14
+ .option('-c, --config <path>', 'Path to manifest file', './docs.ai/manifest.json')
15
+ .option('-v, --verbose', 'Enable verbose logging')
16
+ .option('-w, --watch', 'Watch for file changes')
17
+ .parse();
18
+
19
+ const options = program.opts();
20
+
21
+ async function main() {
22
+ const docsPath = path.resolve(options.docs);
23
+ const configPath = path.resolve(options.config);
24
+
25
+ // Check if docs.ai folder exists
26
+ if (!await fs.pathExists(docsPath)) {
27
+ console.error(`❌ Documentation folder not found: ${docsPath}`);
28
+ console.log('');
29
+ console.log('📖 To get started, create a docs.ai folder in your project:');
30
+ console.log('');
31
+ console.log(' mkdir docs.ai');
32
+ console.log(' echo \'{"name": "My Project Documentation", "globalRules": []}\' > docs.ai/manifest.json');
33
+ console.log(' echo "# Getting Started" > docs.ai/README.md');
34
+ console.log('');
35
+ console.log('Then run: npx doc-bot');
36
+ process.exit(1);
37
+ }
38
+
39
+ // Check if manifest exists, create default if not
40
+ if (!await fs.pathExists(configPath)) {
41
+ console.log('📝 Creating default manifest.json...');
42
+ const defaultManifest = {
43
+ name: 'Project Documentation',
44
+ version: '1.0.0',
45
+ description: 'AI-powered documentation',
46
+ globalRules: [],
47
+ contextualRules: {},
48
+ inference: {
49
+ keywords: {},
50
+ patterns: {}
51
+ }
52
+ };
53
+ await fs.writeJSON(configPath, defaultManifest, { spaces: 2 });
54
+ }
55
+
56
+ const server = new DocsServer({
57
+ docsPath,
58
+ configPath,
59
+ verbose: options.verbose,
60
+ watch: options.watch
61
+ });
62
+
63
+ console.log('🚀 Starting doc-bot...');
64
+ console.log(`📁 Documentation: ${docsPath}`);
65
+ console.log(`⚙️ Configuration: ${configPath}`);
66
+
67
+ if (options.watch) {
68
+ console.log('👀 Watching for file changes...');
69
+ }
70
+
71
+ await server.start();
72
+ console.log('✅ Server started successfully!');
73
+ console.log('');
74
+ console.log('📋 Add this to your Claude Code configuration:');
75
+ console.log('');
76
+ console.log('{');
77
+ console.log(' "mcpServers": {');
78
+ console.log(' "docs": {');
79
+ console.log(` "command": "npx",`);
80
+ console.log(` "args": ["doc-bot", "--docs", "${docsPath}"]`);
81
+ console.log(' }');
82
+ console.log(' }');
83
+ console.log('}');
84
+ console.log('');
85
+ console.log('🔄 Then restart Claude Code');
86
+ }
87
+
88
+ main().catch(error => {
89
+ console.error('❌ Error:', error.message);
90
+ if (options.verbose) {
91
+ console.error(error.stack);
92
+ }
93
+ process.exit(1);
94
+ });
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@afterxleep/doc-bot",
3
+ "version": "1.0.0",
4
+ "description": "Generic MCP server for intelligent documentation access in any project",
5
+ "main": "src/index.js",
6
+ "bin": {
7
+ "doc-bot": "bin/doc-bot.js"
8
+ },
9
+ "scripts": {
10
+ "start": "node src/index.js",
11
+ "test": "jest",
12
+ "test:watch": "jest --watch",
13
+ "test:coverage": "jest --coverage",
14
+ "lint": "eslint src/ bin/ --ext .js",
15
+ "lint:fix": "eslint src/ bin/ --ext .js --fix"
16
+ },
17
+ "keywords": [
18
+ "mcp",
19
+ "documentation",
20
+ "ai",
21
+ "claude",
22
+ "cursor",
23
+ "model-context-protocol",
24
+ "docs",
25
+ "intelligent",
26
+ "inference"
27
+ ],
28
+ "author": "Daniel Loren <daniel@afterxleep.com>",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/afterxleep/doc-bot.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/afterxleep/doc-bot/issues"
36
+ },
37
+ "homepage": "https://github.com/afterxleep/doc-bot#readme",
38
+ "dependencies": {
39
+ "@modelcontextprotocol/sdk": "^0.7.0",
40
+ "commander": "^12.0.0",
41
+ "chokidar": "^3.5.3",
42
+ "fs-extra": "^11.0.0",
43
+ "glob": "^10.3.0",
44
+ "yaml": "^2.3.0"
45
+ },
46
+ "devDependencies": {
47
+ "eslint": "^8.57.0",
48
+ "jest": "^29.7.0",
49
+ "supertest": "^6.3.0"
50
+ },
51
+ "engines": {
52
+ "node": ">=18.0.0"
53
+ },
54
+ "files": [
55
+ "src/",
56
+ "bin/",
57
+ "README.md",
58
+ "LICENSE"
59
+ ]
60
+ }