docs-agent 1.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/CHANGELOG.md +47 -0
- package/LICENSE +21 -0
- package/README.md +239 -0
- package/docs/DEPLOYMENT.md +142 -0
- package/docs/mcp-client-prompt.md +26 -0
- package/docs/reference.md +258 -0
- package/env.example +47 -0
- package/package.json +67 -0
- package/src/CodeSearch.js +125 -0
- package/src/DocsAgent.js +728 -0
- package/src/FileUtility.js +130 -0
- package/src/GitHubApi.js +337 -0
- package/src/LLM.js +463 -0
- package/src/UrlValidator.js +190 -0
- package/src/api.js +107 -0
- package/src/cli.js +0 -0
- package/src/config/principles.diataxis.js +28 -0
- package/src/config/principles.first.js +11 -0
- package/src/config/prompt.docs.vs.code.js +52 -0
- package/src/config/prompt.edit.disruptive.js +9 -0
- package/src/config/prompt.edit.js +40 -0
- package/src/config/prompt.extract.code.js +45 -0
- package/src/config/prompt.formatting.js +38 -0
- package/src/config/prompt.gen.referencedocs.js +181 -0
- package/src/config/prompt.linking.js +14 -0
- package/src/config/prompt.prioritize.js +24 -0
- package/src/config/prompt.relatedfiles.js +14 -0
- package/src/config/prompt.review.js +23 -0
- package/src/config/prompt.scoring.js +9 -0
- package/src/config/prompt.writing.js +13 -0
- package/src/config/rules.linking.js +10 -0
- package/src/index.js +49 -0
- package/src/lib.js +4 -0
- package/src/mcp.js +268 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.1.0](https://github.com/rudderlabs/docs-agent/compare/v1.0.2...v1.1.0) (2025-11-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* authenticate response webhook api calls ([fb7984d](https://github.com/rudderlabs/docs-agent/commit/fb7984d1f2f5127177a16ad5e3f4f7695b675905))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* rollback ai and mcp version upgrade ([fd8f6b5](https://github.com/rudderlabs/docs-agent/commit/fd8f6b5da3150fd8005d8d2fcfe338047e646002))
|
|
14
|
+
|
|
15
|
+
## [1.0.2](https://github.com/rudderlabs/docs-agent/compare/v1.0.1...v1.0.2) (2025-10-18)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* staging port issue ([#62](https://github.com/rudderlabs/docs-agent/issues/62)) ([fbd4d47](https://github.com/rudderlabs/docs-agent/commit/fbd4d475238fe4d1ea019f2e7bae77d0e5968127))
|
|
21
|
+
|
|
22
|
+
## [1.0.1](https://github.com/rudderlabs/docs-agent/compare/v1.0.0...v1.0.1) (2025-10-15)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* add package lock to git ([#57](https://github.com/rudderlabs/docs-agent/issues/57)) ([764eb2f](https://github.com/rudderlabs/docs-agent/commit/764eb2f0f1bf347ebf3448aa3ddaadc8a4f60bea))
|
|
28
|
+
* add write permissions for claude action ([#58](https://github.com/rudderlabs/docs-agent/issues/58)) ([60b338d](https://github.com/rudderlabs/docs-agent/commit/60b338d60aaabeb6fc267ebf83cc41360ec63c64))
|
|
29
|
+
* docker creds in publish-docker workflow ([#55](https://github.com/rudderlabs/docs-agent/issues/55)) ([94f16fb](https://github.com/rudderlabs/docs-agent/commit/94f16fbbd0befa798d2eee6699d13391d8406706))
|
|
30
|
+
|
|
31
|
+
## 1.0.0 (2025-10-07)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* add reference docs and purge unnecessary info ([#29](https://github.com/rudderlabs/docs-agent/issues/29)) ([a613dca](https://github.com/rudderlabs/docs-agent/commit/a613dca4700adb84b7ebb7ea54a80d79d990c1cd))
|
|
37
|
+
* code search using github api ([#38](https://github.com/rudderlabs/docs-agent/issues/38)) ([7c8007d](https://github.com/rudderlabs/docs-agent/commit/7c8007d779563f037b6eb75e313bce4b9e1afb75))
|
|
38
|
+
* generate reference docs from code ([#26](https://github.com/rudderlabs/docs-agent/issues/26)) ([fe507b5](https://github.com/rudderlabs/docs-agent/commit/fe507b561074be2648d20401bae7385e28d3dde0))
|
|
39
|
+
* wofklwo and mcp ([3389829](https://github.com/rudderlabs/docs-agent/commit/3389829ac265bb28e7229bb9a1d95b9fe85944a0))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* fine tune related file context ([#35](https://github.com/rudderlabs/docs-agent/issues/35)) ([d11177d](https://github.com/rudderlabs/docs-agent/commit/d11177d08e115e669a146a4828e272c008a14177))
|
|
45
|
+
* improve alignment with writing and formatting style guide ([#21](https://github.com/rudderlabs/docs-agent/issues/21)) ([029ba53](https://github.com/rudderlabs/docs-agent/commit/029ba53e06a6ac2e09bc4a5d4d05d8cc6df39da5))
|
|
46
|
+
* mcp issue due to std log ([32032c6](https://github.com/rudderlabs/docs-agent/commit/32032c6a73b7fb15c66afebfbcc063c04a19fead))
|
|
47
|
+
* support more arguments in api ([#49](https://github.com/rudderlabs/docs-agent/issues/49)) ([5ef5955](https://github.com/rudderlabs/docs-agent/commit/5ef5955bfc2280e8d5cb38bf94a2f264bf53e557))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 RudderStack
|
|
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,239 @@
|
|
|
1
|
+
# Docs-Agent - AI for Continuous Tech Docs Improvement
|
|
2
|
+
|
|
3
|
+
Helping technical writers, engineering managers, and Open Source authors maintain a technically accurate and comprehensive documentation. Available as MCP server, HTTP APIs, and Node.js Library.
|
|
4
|
+
|
|
5
|
+
> **Built on Diataxis**: This project implements the [Diataxis Documentation Framework](https://diataxis.fr) created by Daniele Procida. Diataxis is a systematic approach to technical documentation authoring. This approach is followed by [Canonical/Ubuntu](https://ubuntu.com/blog/diataxis-a-new-foundation-for-canonical-documentation), Python, Cloudflare, JupyterHub, Gatsby, etc.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
Docs-Agent leverages AI to find and fix issues related to comprehensiblity or technical accuracy.
|
|
10
|
+
|
|
11
|
+
- 🔍 **Audit docs against source code** for technical accuracy
|
|
12
|
+
- 📝 **Auto-fix outdated content** that's out of sync from the source code
|
|
13
|
+
- 🤖 **AI-powered analysis** with human oversight
|
|
14
|
+
- 🔗 **Enhance internal linking** between docs pages and concepts
|
|
15
|
+
- 🎯 **Improve comprehensibility** following Diataxis Documentation Framework principles (you may override it)
|
|
16
|
+
- 🔍 **Code auditing capabilities** to validate documentation against source
|
|
17
|
+
- 🔒 **Path traversal protection** with different access controls for API vs MCP modes
|
|
18
|
+
|
|
19
|
+
> Docs-Agent does not expect its users to learn the details of the Diataxis Documentation Framework
|
|
20
|
+
|
|
21
|
+
> Neither Diataxis, nor Docs-Agent impose any rigid rules, rather Docs-Agent uses the analytical approach provided by Diataxis that emerges from identifying four core user needs which naturally fall into four patterns (tutorials, how-tos, reference, explanation).
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
You may use the Docs-Agent at any of the following three different levels of autonomy vs quality
|
|
26
|
+
|
|
27
|
+
1. (Recommended) In AI IDEs (e.g. Cursor) as MCP server - Best combination of quality and control
|
|
28
|
+
2. In Cursor as rules - Low quality results and potentially negative productivity benefits in some cases
|
|
29
|
+
3. In your systems integrated using HTTP API or Node.js library - Can be made fully autonomous, but takes significant efforts compared to the AI IDE approach
|
|
30
|
+
|
|
31
|
+
### Option 1 (Recommended): Docs-Agent MCP server + Cursor Custom Mode agent
|
|
32
|
+
Great quality and control. But not fully autonomous. Best AI <> Human collaborative experience.
|
|
33
|
+
|
|
34
|
+
<details>
|
|
35
|
+
<summary>
|
|
36
|
+
Why Cursor? And why not **only Cursor**?
|
|
37
|
+
</summary>
|
|
38
|
+
|
|
39
|
+
To leverage Cursor's strength and overcome its limitations by delegating tasks to Docs-Agent MCP server.
|
|
40
|
+
|
|
41
|
+
* Cursor strength: great DX in reviewing and editing the AI suggested changes
|
|
42
|
+
* Cursor weakness: limited control over AI settings frequently results in seemingly correct but technically incorrect output
|
|
43
|
+
* Docs-Agent MCP strength: fine control over AI settings (e.g. temperature, top_p, etc.) and context results in more predictable and technically correct output. Also it is a great choice for extensibility (e.g. include non-ai ops as part of the workflow) and consistency.
|
|
44
|
+
|
|
45
|
+
</details>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
**Set up Docs-Agent MCP server**
|
|
49
|
+
|
|
50
|
+
1. `git clone https://github.com/rudderstack/docs-agent`
|
|
51
|
+
2. `npm install` (use node v20+)
|
|
52
|
+
3. You may test the project by running `npm test` (e2e tests for each task, skips all tests except one at a time, it costs money), `npm run mcp-list`, and `npm run mcp-run`
|
|
53
|
+
|
|
54
|
+
**Integrate Docs-Agent MCP server with Cursor Custom Mode**
|
|
55
|
+
1. Add MCP Server to Cursor (`.cursor/mcp.json`)
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"docs-agent": {
|
|
60
|
+
"command": "/path/to/node",
|
|
61
|
+
"args": ["/path/to/docs-agent/src/index.js"],
|
|
62
|
+
"env": {
|
|
63
|
+
"GITHUB_TOKEN": "github-token-is-needed-for-code-search",
|
|
64
|
+
"REVIEW_AI_SERVICE": "gemini",
|
|
65
|
+
"REVIEW_AI_MODEL": "gemini-2.5-pro-exp-03-25",
|
|
66
|
+
"GOOGLE_GENERATIVE_AI_API_KEY": "secret-api-key",
|
|
67
|
+
"ANTHROPIC_API_KEY": "secret-api-key",
|
|
68
|
+
"ALLOW_DISRUPTIVE_CHANGES": "false",
|
|
69
|
+
"OPENAI_API_KEY": "notinuse",
|
|
70
|
+
"MAX_TOKENS": "8000",
|
|
71
|
+
"MAX_CHANGES": "1",
|
|
72
|
+
"API_DISABLED": "true",
|
|
73
|
+
"MCP_DISABLED": "false",
|
|
74
|
+
"PREFERRED_AI_SERVICE": "anthropic",
|
|
75
|
+
"PREFERRED_AI_MODEL": "claude-3-5-sonnet-20240620",
|
|
76
|
+
"OLLAMA_API_URL": "http://localhost:11434/api/generate",
|
|
77
|
+
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://api.braintrust.dev/otel",
|
|
78
|
+
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <Your API Key>, x-bt-parent=project_id:<Your Project ID>"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
To start with, you only need following env variables - `GITHUB_TOKEN`, `GOOGLE_GENERATIVE_AI_API_KEY`, `ANTHROPIC_API_KEY`, `MCP_DISABLED`. Refer [how to get the necessary secrets](#how-to-get-the-necessary-secrets).
|
|
85
|
+
Make sure `MCP_DISABLED` value is set to `"false"`.
|
|
86
|
+
2. Enable Cursor Custom Mode - `Cursor Settings > Chat (or Features) > Custom Modes (Beta)`
|
|
87
|
+
3. Create your own Custom Mode (I name it Docs Agent) - `Cursor chat box > Mode selection dropdown (where you see Agent by default) > Add custom mode`.
|
|
88
|
+
a. Choose the set of tools you'd want this mode to use. I get the best outcome by disabling `Run (commands)` tool, and enabling all other tools e.g. `MCP`, `edit`, and `Search` (excluding web search).
|
|
89
|
+
b. Choose the choice of your model, I get the best outcome from `Claude 3.5 Sonnet`.
|
|
90
|
+
c. Set a shortcut to quickly start this mode. I use `Cmd+Shift+D` on macOS and `Ctrl+Shift+D` ond other OS.
|
|
91
|
+
4. Set the prompt for the Custom mode. Check out [this example prompt](./docs/mcp-client-prompt.md), it works well for me in Cursor's Custom Mode. You may further personalize it. If you want to pass on a specific file (e.g. your own docs rules) for all docs improvement requests to the MCP server as context, you may choose to specify the absolute path of that file in the prompt so that Cursor (or whichever AI IDE you use).
|
|
92
|
+
|
|
93
|
+
### Option 2: Cursor rules
|
|
94
|
+
> Lowest quality and impact on productivity, but fits in the current human workflow.
|
|
95
|
+
Simply move the `config` folder content to `.cursor/rules` as `.mdc` files. No server required for this.
|
|
96
|
+
|
|
97
|
+
### Option 3: Integrate with your own program using API or Node.js library (e.g. GitHub app)
|
|
98
|
+
> It can be made completely autonomous + Optional feedback via your systems (e.g. GitHub issues)
|
|
99
|
+
|
|
100
|
+
You can integrate Docs Agent with your system either by using Docs Agent as an HTTP API or using as a Node.js library.
|
|
101
|
+
|
|
102
|
+
**3.1: Integrating `docs-agent` as an API**
|
|
103
|
+
|
|
104
|
+
1. `git clone https://github.com/rudderstack/docs-agent`
|
|
105
|
+
2. `npm install` (use node v20+)
|
|
106
|
+
3. `cp env.example .env` update var values (make sure `API_DISABLED=false`; `GOOGLE_GENERATIVE_AI_API_KEY` and `ANTHROPIC_API_KEY` values have valid API keys).
|
|
107
|
+
4. Make sure to add all webhook URLs to `ALLOWED_WEBHOOK_URLS` (comma separated list) where the Docs-Agent is supposed to send back the results when done. Optionally set `RESULTS_WEBHOOK_KEY` to authenticate webhook requests (sent as `x-api-key` header).
|
|
108
|
+
5. `npm test` (e2e tests for each task, skips all tests except one at a time, it costs money)
|
|
109
|
+
6. `npm start`
|
|
110
|
+
|
|
111
|
+
You should be now able to make HTTP requests to following endpoints:
|
|
112
|
+
|
|
113
|
+
- `POST /review --data { content: "docs page code", filepath: "/path/to/file/to/edit", filename: "my.file.md", webhookUrl?: "https://your-app.com/webhook", webhookMetadata?: {...} }` : Returns the improvement suggestions (must provide either the content or filepath). Optionally, provide `webhookUrl` to receive results via webhook POST request (requires `ALLOWED_WEBHOOK_URLS` configuration). If `RESULTS_WEBHOOK_KEY` is set, it will be sent as `x-api-key` header in the webhook request.
|
|
114
|
+
- `POST /prioritize --data { content: "docs page code", review: "improvement suggestions" }` - Returns the prioritized actionable instructions to improve docs incrementally
|
|
115
|
+
- `POST /edit --data { content: "docs page code", editPlan: "specific tasks to improve docs" }` - Returns new file content edited according to the edit plan
|
|
116
|
+
- `GET /health` - Returns health status and system information
|
|
117
|
+
|
|
118
|
+
For more details, check out [reference documentation](./docs/reference.md).
|
|
119
|
+
|
|
120
|
+
**3.2: Integrating `docs-agent` as a Node.js library**
|
|
121
|
+
|
|
122
|
+
1. Link this source code as a node.js package in your Node.js program
|
|
123
|
+
2. Call the neccessary functions as described in [references](./docs/reference.md)
|
|
124
|
+
|
|
125
|
+
For more details, check out [reference documentation](./docs/reference.md).
|
|
126
|
+
|
|
127
|
+
### Security
|
|
128
|
+
|
|
129
|
+
Docs-Agent implements comprehensive security measures to protect against common attacks:
|
|
130
|
+
|
|
131
|
+
- **Path Traversal Protection**: Prevents unauthorized file access with different controls per mode:
|
|
132
|
+
- **API Mode**: Restricts file access to `public/` subdirectory only
|
|
133
|
+
- **MCP Mode**: Allows unrestricted local file access (relies on MCP client permissions and OS-level security)
|
|
134
|
+
- **Both Modes**: Allow validated remote file access (GitHub/GitLab URLs only)
|
|
135
|
+
- **SSRF Protection**: Configurable allowlists for webhook URLs and remote file hosts
|
|
136
|
+
- **API Authentication**: Optional API key authentication for HTTP endpoints
|
|
137
|
+
- **Input Validation**: Comprehensive validation of file paths and URLs
|
|
138
|
+
|
|
139
|
+
For detailed security configuration, see [docs/DEPLOYMENT.md](./docs/DEPLOYMENT.md).
|
|
140
|
+
|
|
141
|
+
### Deployment
|
|
142
|
+
See the deployment guide for containerized, Compose, and bare‑metal instructions: [docs/DEPLOYMENT.md](./docs/DEPLOYMENT.md)
|
|
143
|
+
|
|
144
|
+
## Architecture
|
|
145
|
+
1. **Documentation Analysis Pipeline (Default: Gemini 2.5 Pro Exp)**
|
|
146
|
+
- Document parsing and structure analysis
|
|
147
|
+
- Issue identification and categorization
|
|
148
|
+
- Improvement planning and prioritization
|
|
149
|
+
- Code auditing against source files
|
|
150
|
+
2. **Documentation Editing/Generation Pipeline (Default: Claude 3.5 Sonnet)**
|
|
151
|
+
- Content generation based on approved plans
|
|
152
|
+
- Code example creation and refinement
|
|
153
|
+
- Ensuring documentation framework compatibility e.g. hugo markdownm
|
|
154
|
+
3. **Workflow Orchestration**
|
|
155
|
+
- MCP Tools (reviewDocs, improveDocs, linkifyDocs, auditDocsAgainstCode)
|
|
156
|
+
- REST APIs
|
|
157
|
+
- GitHub webhook handling (Future/Community/Your-Own-App)
|
|
158
|
+
- Issue and PR management (Future/Community/Your-Own-App)
|
|
159
|
+
|
|
160
|
+
## How to get the necessary secrets
|
|
161
|
+
|
|
162
|
+
**GitHub Personal Access Token**
|
|
163
|
+
|
|
164
|
+
1. Go to [GitHub Settings → Developer Settings → Personal Access Tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
|
|
165
|
+
2. Click **"Generate new token"**
|
|
166
|
+
3. Set an expiration date and select required scopes (typically `repo` for repository access)
|
|
167
|
+
4. **Copy the token immediately** - GitHub only shows it once
|
|
168
|
+
5. Set as environment variable: `GITHUB_TOKEN=your_token_here`
|
|
169
|
+
|
|
170
|
+
**Google Generative AI API Key**
|
|
171
|
+
|
|
172
|
+
1. Visit [Google AI Studio](https://ai.google.dev/gemini-api/docs/api-key)
|
|
173
|
+
2. Click **"Get API Key"**
|
|
174
|
+
3. Accept the Terms of Service
|
|
175
|
+
4. Your API key will be auto-generated
|
|
176
|
+
5. Store securely and set as: `GOOGLE_GENERATIVE_AI_API_KEY=your_key_here`
|
|
177
|
+
|
|
178
|
+
**Anthropic API Key**
|
|
179
|
+
|
|
180
|
+
1. Sign up at [Anthropic Console](https://console.anthropic.com/)
|
|
181
|
+
2. Go to **Account Settings → API Keys**
|
|
182
|
+
3. Click **"Create Key"** and provide a name
|
|
183
|
+
4. **Copy and save immediately** - you won't see it again
|
|
184
|
+
5. Set as environment variable: `ANTHROPIC_API_KEY=your_key_here`
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## FAQ
|
|
188
|
+
|
|
189
|
+
<details>
|
|
190
|
+
<summary>
|
|
191
|
+
What are some examples of documentation tasks that can be delgated to Docs-Agent?
|
|
192
|
+
</summary>
|
|
193
|
+
|
|
194
|
+
- Audit docs against source code and ensure technical accuracy
|
|
195
|
+
- Fix docs content that is out of sync from the source code
|
|
196
|
+
- Find comprehensibility and readability issues
|
|
197
|
+
- Align technical docs with the Diataxis framework principles (reference, tutorial, how to guides, explanation)
|
|
198
|
+
- Find deviations from the writing style and align it with your own principles
|
|
199
|
+
- Improve consistency and increase accurate usage of your own technical glossary
|
|
200
|
+
- Find and fix typo
|
|
201
|
+
- Find and fix broken links
|
|
202
|
+
- Improve internal linking of docs pages to other docs pages and concepts/glossary
|
|
203
|
+
- Validate documentation against actual source code implementation
|
|
204
|
+
</details>
|
|
205
|
+
|
|
206
|
+
<details>
|
|
207
|
+
<summary>
|
|
208
|
+
How hard/easy it is to use?
|
|
209
|
+
</summary>
|
|
210
|
+
|
|
211
|
+
**A short chat message is all you need.**
|
|
212
|
+
|
|
213
|
+
When using Docs-Agent as an MCP server in Cursor, simply open the docs page, and ask in plain English what you want to do
|
|
214
|
+
The queries can be broad as well as specific. Some examples:
|
|
215
|
+
- `improve this docs page`
|
|
216
|
+
- `audit this docs page against relevant source code`
|
|
217
|
+
- `improve linking of this page`
|
|
218
|
+
- `users complained about this docs page being too verbose, improve it`
|
|
219
|
+
</details>
|
|
220
|
+
|
|
221
|
+
<details>
|
|
222
|
+
<summary>
|
|
223
|
+
How hard/easy it is for humans to review the Docs-Agent changes?
|
|
224
|
+
</summary>
|
|
225
|
+
|
|
226
|
+
**Incremental changes that can be reviewed under a min.**
|
|
227
|
+
|
|
228
|
+
In the default mode, the Docs-Agent does not aim to improve everything in one go. That would make the life of humans harder to understand the changes and thus making it hard and even slow to bring positive change. Instead, Docs-Agent follows incremental approach - one tiny easy to review PR at a time. Once Docs-Agent finds the gaps in the documentation, it prioritizes one impactful change, and makes only the change that would be quick to review without much cognitive overload. For example: in order to align docs with Diataxis principles, it would require tonnes of changes to convert existing docs to different Diataxis types such as reference, tutotrial, how to, and explanation. When you ask Docs-Agent to improve any docs page, it will figure out the Diataxis type that current page closely matches with, how well it does in the following Diataxis principles for that type, and introduce one tiny change to align its content more with that type.
|
|
229
|
+
</details>
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
This project is licensed under the [MIT License](./LICENSE).
|
|
236
|
+
|
|
237
|
+
### Credits
|
|
238
|
+
|
|
239
|
+
**Diataxis Framework** by [Daniele Procida](https://github.com/evildmp) • [diataxis.fr](https://diataxis.fr) • Licensed under [CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
## Deployment Guide
|
|
2
|
+
|
|
3
|
+
This guide covers deploying Docs-Agent as a container (recommended), with Docker Compose, or directly on a host (bare metal). It exposes an HTTP API on port 3001 when `API_DISABLED=false` and can be run as an MCP server with `MCP_DISABLED=false`.
|
|
4
|
+
|
|
5
|
+
### Prerequisites
|
|
6
|
+
- Node.js v20+ (bare-metal or MCP usage)
|
|
7
|
+
- Docker 24+ (for containerized deployment)
|
|
8
|
+
- Optional: Docker Compose v2+
|
|
9
|
+
- Required secrets (at least):
|
|
10
|
+
- `GOOGLE_GENERATIVE_AI_API_KEY`
|
|
11
|
+
- `ANTHROPIC_API_KEY`
|
|
12
|
+
- `GITHUB_TOKEN` (for code search)
|
|
13
|
+
|
|
14
|
+
Additional configuration (optional):
|
|
15
|
+
- `API_KEY` for API security
|
|
16
|
+
- `PREFERRED_AI_SERVICE`, `PREFERRED_AI_MODEL`, `REVIEW_AI_SERVICE`, `REVIEW_AI_MODEL`
|
|
17
|
+
- `OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_EXPORTER_OTLP_HEADERS` for observability
|
|
18
|
+
- `MAX_TOKENS`, `MAX_CHANGES`, `ALLOW_DISRUPTIVE_CHANGES`
|
|
19
|
+
- SSRF Protection:
|
|
20
|
+
- `ALLOWED_WEBHOOK_URLS` for webhook endpoints (exact URLs only)
|
|
21
|
+
- `RESULTS_WEBHOOK_KEY` for authenticating webhook requests (optional, sent as `x-api-key` header)
|
|
22
|
+
- `REMOTE_FILE_ALLOWED_HOSTS` for remote file access (hostnames only)
|
|
23
|
+
- `REMOTE_FILE_ALLOW_CUSTOM_HOSTS` to enable custom hosts (default: false)
|
|
24
|
+
|
|
25
|
+
Environment defaults are shown in `env.example` and `docker-compose.yml`.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Option A: Docker (single container)
|
|
30
|
+
1. Build the image:
|
|
31
|
+
```bash
|
|
32
|
+
docker build -t docs-agent:latest .
|
|
33
|
+
```
|
|
34
|
+
2. Run the container (API mode):
|
|
35
|
+
```bash
|
|
36
|
+
docker run --rm \
|
|
37
|
+
-p 3001:3001 \
|
|
38
|
+
-e NODE_ENV=production \
|
|
39
|
+
-e PORT=3001 \
|
|
40
|
+
-e API_DISABLED=false \
|
|
41
|
+
-e MCP_DISABLED=true \
|
|
42
|
+
-e API_KEY=secret_api_key \
|
|
43
|
+
-e GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_key \
|
|
44
|
+
-e ANTHROPIC_API_KEY=your_anthropic_key \
|
|
45
|
+
-e GITHUB_TOKEN=your_github_pat \
|
|
46
|
+
-e ALLOWED_WEBHOOK_URLS=https://github.app.url/api/comment \
|
|
47
|
+
-e RESULTS_WEBHOOK_KEY=your_webhook_auth_key \
|
|
48
|
+
-e REMOTE_FILE_ALLOWED_HOSTS=raw.githubusercontent.com \
|
|
49
|
+
docs-agent:latest
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Health check: `GET http://localhost:3001/health` should return 200.
|
|
53
|
+
|
|
54
|
+
Notes
|
|
55
|
+
- The image runs as a non-root `nodejs` user.
|
|
56
|
+
- Port 3001 is exposed; adjust with `-e PORT=... -p host:container`.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### Option B: Docker Compose (recommended for local/dev)
|
|
61
|
+
Use the provided `docker-compose.yml`:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
docker compose up --build
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then check: `curl http://localhost:3001/health`.
|
|
68
|
+
|
|
69
|
+
Customize environment by editing `docker-compose.yml` or using an `.env` file. Ensure you set valid keys for:
|
|
70
|
+
- `GOOGLE_GENERATIVE_AI_API_KEY`
|
|
71
|
+
- `ANTHROPIC_API_KEY`
|
|
72
|
+
- `GITHUB_TOKEN`
|
|
73
|
+
- `API_KEY`
|
|
74
|
+
|
|
75
|
+
For SSRF protection, configure:
|
|
76
|
+
- `ALLOWED_WEBHOOK_URLS` - exact webhook URLs (comma-separated)
|
|
77
|
+
- `RESULTS_WEBHOOK_KEY` - API key to authenticate webhook requests (optional, sent as `x-api-key` header)
|
|
78
|
+
- `REMOTE_FILE_ALLOWED_HOSTS` - allowed hosts for remote file access
|
|
79
|
+
- `REMOTE_FILE_ALLOW_CUSTOM_HOSTS` - set to "true" to enable custom hosts
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### Option C: Bare metal (Node.js on host)
|
|
84
|
+
1. Install dependencies:
|
|
85
|
+
```bash
|
|
86
|
+
npm ci --only=production
|
|
87
|
+
```
|
|
88
|
+
2. Configure environment (copy and edit):
|
|
89
|
+
```bash
|
|
90
|
+
cp env.example .env
|
|
91
|
+
# edit .env -> set API_DISABLED=false and add your keys
|
|
92
|
+
```
|
|
93
|
+
3. Start the server:
|
|
94
|
+
```bash
|
|
95
|
+
npm start
|
|
96
|
+
```
|
|
97
|
+
4. Verify:
|
|
98
|
+
```bash
|
|
99
|
+
curl http://localhost:3001/health
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For MCP usage (no HTTP API), set `MCP_DISABLED=false` and `API_DISABLED=true`, then point your MCP client (e.g., Cursor Custom Mode) to `node src/index.js`. See `README.md` for an example MCP client configuration.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### Configuration Reference
|
|
107
|
+
- `API_DISABLED` (default true in example): set to `false` to enable HTTP API
|
|
108
|
+
- `API_KEY`, always set this to a secret value to secure API endpoints
|
|
109
|
+
- `MCP_DISABLED`: set to `false` to enable MCP server tools
|
|
110
|
+
- `GOOGLE_GENERATIVE_AI_API_KEY`, `ANTHROPIC_API_KEY`: required for AI operations
|
|
111
|
+
- `GITHUB_TOKEN`: required for auditing docs against code in private/public repos
|
|
112
|
+
- `PREFERRED_AI_SERVICE`/`MODEL` and `REVIEW_AI_SERVICE`/`MODEL`: control model choices
|
|
113
|
+
- `MAX_TOKENS`, `MAX_CHANGES`, `ALLOW_DISRUPTIVE_CHANGES`: safety/quality controls
|
|
114
|
+
- Observability: set `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS` to enable OTEL traces
|
|
115
|
+
- SSRF Protection:
|
|
116
|
+
- `ALLOWED_WEBHOOK_URLS`: exact webhook URLs only (comma-separated)
|
|
117
|
+
- `RESULTS_WEBHOOK_KEY`: API key for webhook authentication (optional, sent as `x-api-key` header)
|
|
118
|
+
- `REMOTE_FILE_ALLOWED_HOSTS`: allowed hosts for remote file reads (comma-separated)
|
|
119
|
+
- `REMOTE_FILE_ALLOW_CUSTOM_HOSTS`: enable custom hosts (default: false)
|
|
120
|
+
|
|
121
|
+
All variables and defaults are documented in `env.example`.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### Security and Operations
|
|
126
|
+
- Provide secrets via environment variables or secret stores (never bake into images).
|
|
127
|
+
- The container uses a non-root user and a health check.
|
|
128
|
+
- Run behind an API gateway or reverse proxy in production; add rate limits and auth as needed.
|
|
129
|
+
- **Path Traversal Protection**:
|
|
130
|
+
- API mode: Restricts file access to `public/` subdirectory only
|
|
131
|
+
- MCP mode: Allows unrestricted local file access (relies on MCP client permissions)
|
|
132
|
+
- Both modes: Allow validated remote file access (GitHub/GitLab URLs)
|
|
133
|
+
- SSRF Protection: Configure webhook and remote file allowlists to prevent unauthorized requests.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### Troubleshooting
|
|
138
|
+
- Health endpoint not ready: allow the container start period defined in Dockerfile/Compose.
|
|
139
|
+
- 401/403 errors from code search: verify `GITHUB_TOKEN` scopes (typically `repo`).
|
|
140
|
+
- AI errors: verify keys and model names; ensure region/product access with providers.
|
|
141
|
+
|
|
142
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
You are a helpful team member to coordinate documentation improvements tasks between the user and the MCP tools such as docs-agent.
|
|
2
|
+
User will ask you for documentation improvements tasks or advice.
|
|
3
|
+
You will then choose the appropriate MCP tools from docs-agent based on the task requirements.
|
|
4
|
+
|
|
5
|
+
## MCP Tool Usage Guidelines
|
|
6
|
+
- Always use the docs-agent's tools for docs improvement to get the improved docs content.
|
|
7
|
+
- Make sure to pass the necessary content to docs-agent such as the file content and context e.g. project structure, etc.
|
|
8
|
+
- Always send the glossary page content as glossary parameter for the tool that requires it.
|
|
9
|
+
- For tools that require specific files or information, find the related files or information from the source code or project context.
|
|
10
|
+
- If the RudderStack documentation style guide rule (rudderstack-style.mdc) is available, provide its complete content in the custom instructions to ensure that the docs-agent output follows the RudderStack style.
|
|
11
|
+
- The file paths must always be either absolute path or a remote url path
|
|
12
|
+
- Always apply the docs-agent results as it is in the code immediately after they are received
|
|
13
|
+
- Always show the audit or review results to ensure the reasoning behind the changes
|
|
14
|
+
|
|
15
|
+
## Finding related files
|
|
16
|
+
- Based on the user goal, decide which files are the most relevant files for additional context
|
|
17
|
+
- A file mentioned in the page could be a relevant file if the understanding of the page depends on that file content
|
|
18
|
+
- Sibling files under the immediate parent folder are sometimes relevant as they relate to the same concept
|
|
19
|
+
- Do not make up the filepath, always list files and then pick the filepath from there
|
|
20
|
+
|
|
21
|
+
## Boundaries
|
|
22
|
+
- **Do not** make any additional changes to the docs-agent tool output, your job is to only apply those changes to current file content as it is.
|
|
23
|
+
- Make sure the final file content matches the agent's version completely after applying the diff.
|
|
24
|
+
- Remember to apply all the changes as it is, no additional changes or addition or deletion from your side.
|
|
25
|
+
- Do not make changes to the file content that is not related to the returned docs content.
|
|
26
|
+
- Do not ask the user to apply the changes returned by `improveDocs` or `editDocs` tools — just apply them directly.
|