slicejs-mcp 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 +154 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/get-doc-content.d.ts +20 -0
- package/dist/tools/get-doc-content.d.ts.map +1 -0
- package/dist/tools/get-doc-content.js +39 -0
- package/dist/tools/get-doc-content.js.map +1 -0
- package/dist/tools/get-documentation.d.ts +20 -0
- package/dist/tools/get-documentation.d.ts.map +1 -0
- package/dist/tools/get-documentation.js +37 -0
- package/dist/tools/get-documentation.js.map +1 -0
- package/dist/tools/get-llm-context.d.ts +8 -0
- package/dist/tools/get-llm-context.d.ts.map +1 -0
- package/dist/tools/get-llm-context.js +25 -0
- package/dist/tools/get-llm-context.js.map +1 -0
- package/dist/tools/get-llm-full-context.d.ts +8 -0
- package/dist/tools/get-llm-full-context.d.ts.map +1 -0
- package/dist/tools/get-llm-full-context.js +25 -0
- package/dist/tools/get-llm-full-context.js.map +1 -0
- package/dist/tools/list-docs.d.ts +8 -0
- package/dist/tools/list-docs.d.ts.map +1 -0
- package/dist/tools/list-docs.js +17 -0
- package/dist/tools/list-docs.js.map +1 -0
- package/dist/tools/list-documentation.d.ts +8 -0
- package/dist/tools/list-documentation.d.ts.map +1 -0
- package/dist/tools/list-documentation.js +16 -0
- package/dist/tools/list-documentation.js.map +1 -0
- package/dist/tools/search-docs.d.ts +20 -0
- package/dist/tools/search-docs.d.ts.map +1 -0
- package/dist/tools/search-docs.js +41 -0
- package/dist/tools/search-docs.js.map +1 -0
- package/dist/tools/search-documentation.d.ts +20 -0
- package/dist/tools/search-documentation.d.ts.map +1 -0
- package/dist/tools/search-documentation.js +39 -0
- package/dist/tools/search-documentation.js.map +1 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +104 -0
- package/dist/utils.js.map +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Slice.js Documentation MCP
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that provides access to Slice.js documentation from the official GitHub repository. This server allows AI assistants and tools to query, search, and retrieve documentation seamlessly.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Dynamic Documentation Discovery**: Automatically discovers and indexes all documentation files from the GitHub repo
|
|
8
|
+
- **Intelligent Caching**: Infinite session cache to minimize API requests and improve performance
|
|
9
|
+
- **Full-Text Search**: Search across all documentation with keyword matching
|
|
10
|
+
- **Content Retrieval**: Fetch specific documentation pages or the complete documentation bundle
|
|
11
|
+
- **Lazy Initialization**: Docs structure is loaded on-demand when first needed
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### Global Installation (Recommended)
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g slicejs-mcp
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Using npx (No Installation Required)
|
|
21
|
+
```bash
|
|
22
|
+
npx slicejs-mcp
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
The MCP server runs as a stdio-based service, perfect for integration with AI assistants and MCP-compatible tools.
|
|
28
|
+
|
|
29
|
+
### Basic Usage
|
|
30
|
+
```bash
|
|
31
|
+
npx slicejs-mcp
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Integration with MCP Clients
|
|
35
|
+
This server is designed to work with MCP-compatible clients. When launched, it exposes 4 tools:
|
|
36
|
+
|
|
37
|
+
## Tools
|
|
38
|
+
|
|
39
|
+
### 1. `list_docs`
|
|
40
|
+
Returns a list of all available documentation sections and categories.
|
|
41
|
+
|
|
42
|
+
**Parameters:** None
|
|
43
|
+
|
|
44
|
+
**Response:** JSON array of documentation items with id, title, and path.
|
|
45
|
+
|
|
46
|
+
**Example:**
|
|
47
|
+
```json
|
|
48
|
+
[
|
|
49
|
+
{
|
|
50
|
+
"id": "getting-started",
|
|
51
|
+
"title": "Getting Started",
|
|
52
|
+
"path": "markdown/getting-started.md"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 2. `search_docs`
|
|
58
|
+
Searches across all documentation using keywords or phrases.
|
|
59
|
+
|
|
60
|
+
**Parameters:**
|
|
61
|
+
- `query` (string, required): Search term
|
|
62
|
+
- `max_results` (number, optional, default: 5): Maximum number of results
|
|
63
|
+
|
|
64
|
+
**Response:** JSON array of search results with snippets and metadata.
|
|
65
|
+
|
|
66
|
+
### 3. `get_doc_content`
|
|
67
|
+
Fetches the full content of specific documentation page(s).
|
|
68
|
+
|
|
69
|
+
**Parameters:**
|
|
70
|
+
- `doc_id` (string or string[], required): Documentation ID(s) to fetch
|
|
71
|
+
- `include_metadata` (boolean, optional, default: false): Include additional metadata
|
|
72
|
+
|
|
73
|
+
**Response:** JSON object(s) with document content, title, and optional metadata.
|
|
74
|
+
|
|
75
|
+
### 4. `get_llm_full_context`
|
|
76
|
+
Fetches the complete documentation bundle (~2000 lines) for comprehensive LLM context.
|
|
77
|
+
|
|
78
|
+
**Parameters:** None
|
|
79
|
+
|
|
80
|
+
**Response:** Complete documentation text
|
|
81
|
+
|
|
82
|
+
**Note:** This consumes considerable tokens but provides all documentation in one request.
|
|
83
|
+
|
|
84
|
+
## Examples
|
|
85
|
+
|
|
86
|
+
### List all documentation
|
|
87
|
+
```javascript
|
|
88
|
+
// Via MCP client
|
|
89
|
+
await callTool("list_docs", {});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Search for routing information
|
|
93
|
+
```javascript
|
|
94
|
+
await callTool("search_docs", {
|
|
95
|
+
query: "routing",
|
|
96
|
+
max_results: 3
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Get specific documentation
|
|
101
|
+
```javascript
|
|
102
|
+
await callTool("get_doc_content", {
|
|
103
|
+
doc_id: "getting-started/routing"
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Get full documentation context
|
|
108
|
+
```javascript
|
|
109
|
+
await callTool("get_llm_full_context", {});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Architecture
|
|
113
|
+
|
|
114
|
+
- **Source**: Documentation fetched from https://github.com/VKneider/slicejs_docs
|
|
115
|
+
- **Caching**: Infinite session cache prevents redundant API calls
|
|
116
|
+
- **Initialization**: Lazy loading of document structure on first tool use
|
|
117
|
+
- **Rate Limiting**: Optimized to stay within GitHub API limits (60 req/hour)
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
### Prerequisites
|
|
122
|
+
- Node.js >= 18
|
|
123
|
+
- npm or yarn
|
|
124
|
+
|
|
125
|
+
### Setup
|
|
126
|
+
```bash
|
|
127
|
+
git clone <repo>
|
|
128
|
+
cd slicejs-mcp
|
|
129
|
+
npm install
|
|
130
|
+
npm run build
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Running Locally
|
|
134
|
+
```bash
|
|
135
|
+
npm start
|
|
136
|
+
# or
|
|
137
|
+
node dist/index.js
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Testing with MCP Inspector
|
|
141
|
+
```bash
|
|
142
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Contributing
|
|
146
|
+
|
|
147
|
+
Contributions welcome! Please ensure:
|
|
148
|
+
- All tools maintain backward compatibility
|
|
149
|
+
- Cache behavior is preserved
|
|
150
|
+
- Error handling is robust
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FastMCP } from "fastmcp";
|
|
2
|
+
import { listDocsTool } from "./tools/list-docs.js";
|
|
3
|
+
import { searchDocsTool } from "./tools/search-docs.js";
|
|
4
|
+
import { getDocContentTool } from "./tools/get-doc-content.js";
|
|
5
|
+
import { getLlmFullContextTool } from "./tools/get-llm-full-context.js";
|
|
6
|
+
const server = new FastMCP({
|
|
7
|
+
name: "Slice.js Documentation MCP",
|
|
8
|
+
version: "1.0.0",
|
|
9
|
+
});
|
|
10
|
+
server.addTool(listDocsTool);
|
|
11
|
+
server.addTool(searchDocsTool);
|
|
12
|
+
server.addTool(getDocContentTool);
|
|
13
|
+
server.addTool(getLlmFullContextTool);
|
|
14
|
+
server.start({
|
|
15
|
+
transportType: "stdio",
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC;IACzB,IAAI,EAAE,4BAA4B;IAClC,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAC7B,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AAC/B,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAClC,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEtC,MAAM,CAAC,KAAK,CAAC;IACX,aAAa,EAAE,OAAO;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const getDocContentTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodObject<{
|
|
6
|
+
doc_id: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
7
|
+
include_metadata: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
doc_id: string | string[];
|
|
10
|
+
include_metadata: boolean;
|
|
11
|
+
}, {
|
|
12
|
+
doc_id: string | string[];
|
|
13
|
+
include_metadata?: boolean | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
execute: (args: {
|
|
16
|
+
doc_id: string | string[];
|
|
17
|
+
include_metadata: boolean;
|
|
18
|
+
}) => Promise<string>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=get-doc-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-doc-content.d.ts","sourceRoot":"","sources":["../../src/tools/get-doc-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;oBAON;QAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAA;KAAE;CA+B/E,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DOCS_STRUCTURE, fetchDocContent, initializeDocsStructure, isInitialized } from "../utils.js";
|
|
3
|
+
export const getDocContentTool = {
|
|
4
|
+
name: "get_doc_content",
|
|
5
|
+
description: "Fetches full content of specific doc page(s)",
|
|
6
|
+
parameters: z.object({
|
|
7
|
+
doc_id: z.union([z.string(), z.array(z.string())]),
|
|
8
|
+
include_metadata: z.boolean().optional().default(false),
|
|
9
|
+
}),
|
|
10
|
+
execute: async (args) => {
|
|
11
|
+
if (!isInitialized)
|
|
12
|
+
await initializeDocsStructure();
|
|
13
|
+
const { doc_id, include_metadata } = args;
|
|
14
|
+
const ids = Array.isArray(doc_id) ? doc_id : [doc_id];
|
|
15
|
+
const results = [];
|
|
16
|
+
for (const id of ids) {
|
|
17
|
+
const doc = DOCS_STRUCTURE.find(d => d.id === id);
|
|
18
|
+
if (!doc)
|
|
19
|
+
continue;
|
|
20
|
+
const content = await fetchDocContent(id);
|
|
21
|
+
if (!content)
|
|
22
|
+
continue;
|
|
23
|
+
const result = {
|
|
24
|
+
doc_id: id,
|
|
25
|
+
title: doc.title,
|
|
26
|
+
content,
|
|
27
|
+
};
|
|
28
|
+
if (include_metadata) {
|
|
29
|
+
result.metadata = {
|
|
30
|
+
path: doc.path,
|
|
31
|
+
fetched_at: new Date().toISOString(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
results.push(result);
|
|
35
|
+
}
|
|
36
|
+
return JSON.stringify(results.length === 1 ? results[0] : results);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=get-doc-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-doc-content.js","sourceRoot":"","sources":["../../src/tools/get-doc-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtG,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,8CAA8C;IAC3D,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CA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AAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const getDocumentationTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodObject<{
|
|
6
|
+
doc_id: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
7
|
+
include_metadata: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
doc_id: string | string[];
|
|
10
|
+
include_metadata: boolean;
|
|
11
|
+
}, {
|
|
12
|
+
doc_id: string | string[];
|
|
13
|
+
include_metadata?: boolean | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
execute: (args: {
|
|
16
|
+
doc_id: string | string[];
|
|
17
|
+
include_metadata: boolean;
|
|
18
|
+
}) => Promise<string>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=get-documentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-documentation.d.ts","sourceRoot":"","sources":["../../src/tools/get-documentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;oBAOT;QAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAA;KAAE;CA8B/E,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DOCS_STRUCTURE, fetchDocContent } from "../utils.js";
|
|
3
|
+
export const getDocumentationTool = {
|
|
4
|
+
name: "get_documentation",
|
|
5
|
+
description: "Fetches full content of specific doc page(s)",
|
|
6
|
+
parameters: z.object({
|
|
7
|
+
doc_id: z.union([z.string(), z.array(z.string())]),
|
|
8
|
+
include_metadata: z.boolean().optional().default(false),
|
|
9
|
+
}),
|
|
10
|
+
execute: async (args) => {
|
|
11
|
+
const { doc_id, include_metadata } = args;
|
|
12
|
+
const ids = Array.isArray(doc_id) ? doc_id : [doc_id];
|
|
13
|
+
const results = [];
|
|
14
|
+
for (const id of ids) {
|
|
15
|
+
const doc = DOCS_STRUCTURE.find(d => d.id === id);
|
|
16
|
+
if (!doc)
|
|
17
|
+
continue;
|
|
18
|
+
const content = await fetchDocContent(id);
|
|
19
|
+
if (!content)
|
|
20
|
+
continue;
|
|
21
|
+
const result = {
|
|
22
|
+
doc_id: id,
|
|
23
|
+
title: doc.title,
|
|
24
|
+
content,
|
|
25
|
+
};
|
|
26
|
+
if (include_metadata) {
|
|
27
|
+
result.metadata = {
|
|
28
|
+
path: doc.path,
|
|
29
|
+
fetched_at: new Date().toISOString(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
results.push(result);
|
|
33
|
+
}
|
|
34
|
+
return JSON.stringify(results.length === 1 ? results[0] : results);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=get-documentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-documentation.js","sourceRoot":"","sources":["../../src/tools/get-documentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,8CAA8C;IAC3D,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClD,gBAAgB,EAAE,C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m-context.d.ts","sourceRoot":"","sources":["../../src/tools/get-llm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,iBAAiB;;;;;CAmB7B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { getCached, setCache, BASE_URL } from "../utils.js";
|
|
3
|
+
export const getLlmContextTool = {
|
|
4
|
+
name: "get_llm_context",
|
|
5
|
+
description: "Fetches the complete llm.txt from the repository",
|
|
6
|
+
parameters: z.object({}),
|
|
7
|
+
execute: async () => {
|
|
8
|
+
const cached = getCached('llm.txt');
|
|
9
|
+
if (cached)
|
|
10
|
+
return cached;
|
|
11
|
+
const url = `${BASE_URL}llm.txt`;
|
|
12
|
+
try {
|
|
13
|
+
const response = await fetch(url);
|
|
14
|
+
if (!response.ok)
|
|
15
|
+
throw new Error(`HTTP ${response.status}`);
|
|
16
|
+
const content = await response.text();
|
|
17
|
+
setCache('llm.txt', content);
|
|
18
|
+
return content;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return `Error fetching llm.txt: ${error}`;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=get-llm-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-llm-context.js","sourceRoot":"","sources":["../../src/tools/get-llm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,kDAAkD;IAC/D,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACxB,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;QACpC,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAE1B,MAAM,GAAG,GAAG,GAAG,QAAQ,SAAS,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7D,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACtC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC7B,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,2BAA2B,KAAK,EAAE,CAAC;QAC5C,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-llm-full-context.d.ts","sourceRoot":"","sources":["../../src/tools/get-llm-full-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,qBAAqB;;;;;CAmBjC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { getCached, setCache, BASE_URL } from "../utils.js";
|
|
3
|
+
export const getLlmFullContextTool = {
|
|
4
|
+
name: "get_llm_full_context",
|
|
5
|
+
description: "Fetches the complete llm.txt from the repository (~2000 lines, consumes considerable tokens but provides all documentation in one go)",
|
|
6
|
+
parameters: z.object({}),
|
|
7
|
+
execute: async () => {
|
|
8
|
+
const cached = getCached('llm.txt');
|
|
9
|
+
if (cached)
|
|
10
|
+
return cached;
|
|
11
|
+
const url = `${BASE_URL}llm.txt`;
|
|
12
|
+
try {
|
|
13
|
+
const response = await fetch(url);
|
|
14
|
+
if (!response.ok)
|
|
15
|
+
throw new Error(`HTTP ${response.status}`);
|
|
16
|
+
const content = await response.text();
|
|
17
|
+
setCache('llm.txt', content);
|
|
18
|
+
return content;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return `Error fetching llm.txt: ${error}`;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=get-llm-full-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-llm-full-context.js","sourceRoot":"","sources":["../../src/tools/get-llm-full-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,uIAAuI;IACpJ,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACxB,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;QACpC,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAE1B,MAAM,GAAG,GAAG,GAAG,QAAQ,SAAS,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7D,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACtC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC7B,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,2BAA2B,KAAK,EAAE,CAAC;QAC5C,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-docs.d.ts","sourceRoot":"","sources":["../../src/tools/list-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,YAAY;;;;;CAYxB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DOCS_STRUCTURE, initializeDocsStructure, isInitialized } from "../utils.js";
|
|
3
|
+
export const listDocsTool = {
|
|
4
|
+
name: "list_docs",
|
|
5
|
+
description: "Returns available documentation sections/categories",
|
|
6
|
+
parameters: z.object({}),
|
|
7
|
+
execute: async () => {
|
|
8
|
+
if (!isInitialized)
|
|
9
|
+
await initializeDocsStructure();
|
|
10
|
+
return JSON.stringify(DOCS_STRUCTURE.map(doc => ({
|
|
11
|
+
id: doc.id,
|
|
12
|
+
title: doc.title,
|
|
13
|
+
path: doc.path,
|
|
14
|
+
})));
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=list-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-docs.js","sourceRoot":"","sources":["../../src/tools/list-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,qDAAqD;IAClE,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACxB,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,IAAI,CAAC,aAAa;YAAE,MAAM,uBAAuB,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/C,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAC,CAAC,CAAC,CAAC;IACP,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-documentation.d.ts","sourceRoot":"","sources":["../../src/tools/list-documentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,qBAAqB;;;;;CAYjC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DOCS_STRUCTURE, initializeDocsStructure } from "../utils.js";
|
|
3
|
+
export const listDocumentationTool = {
|
|
4
|
+
name: "list_documentation",
|
|
5
|
+
description: "Returns available documentation sections/categories",
|
|
6
|
+
parameters: z.object({}),
|
|
7
|
+
execute: async () => {
|
|
8
|
+
await initializeDocsStructure();
|
|
9
|
+
return JSON.stringify(DOCS_STRUCTURE.map(doc => ({
|
|
10
|
+
id: doc.id,
|
|
11
|
+
title: doc.title,
|
|
12
|
+
path: doc.path,
|
|
13
|
+
})));
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=list-documentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-documentation.js","sourceRoot":"","sources":["../../src/tools/list-documentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,qDAAqD;IAClE,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACxB,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,MAAM,uBAAuB,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/C,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAC,CAAC,CAAC,CAAC;IACP,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const searchDocsTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodObject<{
|
|
6
|
+
query: z.ZodString;
|
|
7
|
+
max_results: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
query: string;
|
|
10
|
+
max_results: number;
|
|
11
|
+
}, {
|
|
12
|
+
query: string;
|
|
13
|
+
max_results?: number | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
execute: (args: {
|
|
16
|
+
query: string;
|
|
17
|
+
max_results: number;
|
|
18
|
+
}) => Promise<string>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=search-docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-docs.d.ts","sourceRoot":"","sources":["../../src/tools/search-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;oBAOH;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;CA6B7D,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DOCS_STRUCTURE, fetchDocContent, initializeDocsStructure, isInitialized } from "../utils.js";
|
|
3
|
+
export const searchDocsTool = {
|
|
4
|
+
name: "search_docs",
|
|
5
|
+
description: "Searches across all docs by keyword/phrase",
|
|
6
|
+
parameters: z.object({
|
|
7
|
+
query: z.string(),
|
|
8
|
+
max_results: z.number().optional().default(5),
|
|
9
|
+
}),
|
|
10
|
+
execute: async (args) => {
|
|
11
|
+
if (!isInitialized)
|
|
12
|
+
await initializeDocsStructure();
|
|
13
|
+
const { query, max_results } = args;
|
|
14
|
+
const results = [];
|
|
15
|
+
for (const doc of DOCS_STRUCTURE) {
|
|
16
|
+
const content = await fetchDocContent(doc.id);
|
|
17
|
+
if (!content)
|
|
18
|
+
continue;
|
|
19
|
+
const lines = content.split('\n');
|
|
20
|
+
for (let i = 0; i < lines.length; i++) {
|
|
21
|
+
const line = lines[i];
|
|
22
|
+
if (line.toLowerCase().includes(query.toLowerCase())) {
|
|
23
|
+
const snippet = line.trim();
|
|
24
|
+
results.push({
|
|
25
|
+
doc_id: doc.id,
|
|
26
|
+
title: doc.title,
|
|
27
|
+
relevance_score: 1, // simple match
|
|
28
|
+
snippet,
|
|
29
|
+
path: doc.path,
|
|
30
|
+
});
|
|
31
|
+
if (results.length >= max_results)
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (results.length >= max_results)
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
return JSON.stringify(results);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=search-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-docs.js","sourceRoot":"","sources":["../../src/tools/search-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtG,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,I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MAAM;gBAC3C,CAAC;YACH,CAAC;YACD,IAAI,OAAO,CAAC,MAAM,IAAI,WAAW;gBAAE,MAAM;QAC3C,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const searchDocumentationTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodObject<{
|
|
6
|
+
query: z.ZodString;
|
|
7
|
+
max_results: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
query: string;
|
|
10
|
+
max_results: number;
|
|
11
|
+
}, {
|
|
12
|
+
query: string;
|
|
13
|
+
max_results?: number | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
execute: (args: {
|
|
16
|
+
query: string;
|
|
17
|
+
max_results: number;
|
|
18
|
+
}) => Promise<string>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=search-documentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-documentation.d.ts","sourceRoot":"","sources":["../../src/tools/search-documentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;oBAOZ;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;CA4B7D,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DOCS_STRUCTURE, fetchDocContent } from "../utils.js";
|
|
3
|
+
export const searchDocumentationTool = {
|
|
4
|
+
name: "search_documentation",
|
|
5
|
+
description: "Searches across all docs by keyword/phrase",
|
|
6
|
+
parameters: z.object({
|
|
7
|
+
query: z.string(),
|
|
8
|
+
max_results: z.number().optional().default(5),
|
|
9
|
+
}),
|
|
10
|
+
execute: async (args) => {
|
|
11
|
+
const { query, max_results } = args;
|
|
12
|
+
const results = [];
|
|
13
|
+
for (const doc of DOCS_STRUCTURE) {
|
|
14
|
+
const content = await fetchDocContent(doc.id);
|
|
15
|
+
if (!content)
|
|
16
|
+
continue;
|
|
17
|
+
const lines = content.split('\n');
|
|
18
|
+
for (let i = 0; i < lines.length; i++) {
|
|
19
|
+
const line = lines[i];
|
|
20
|
+
if (line.toLowerCase().includes(query.toLowerCase())) {
|
|
21
|
+
const snippet = line.trim();
|
|
22
|
+
results.push({
|
|
23
|
+
doc_id: doc.id,
|
|
24
|
+
title: doc.title,
|
|
25
|
+
relevance_score: 1, // simple match
|
|
26
|
+
snippet,
|
|
27
|
+
path: doc.path,
|
|
28
|
+
});
|
|
29
|
+
if (results.length >= max_results)
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (results.length >= max_results)
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
return JSON.stringify(results);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=search-documentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-documentation.js","sourceRoot":"","sources":["../../src/tools/search-documentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,4CAA4C;IACzD,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;KAC9C,CAAC;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: number;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const CACHE_TTL: number;
|
|
6
|
+
export declare function getCached(key: string): string | null;
|
|
7
|
+
export declare function setCache(key: string, content: string): void;
|
|
8
|
+
export declare const BASE_URL = "https://raw.githubusercontent.com/VKneider/slicejs_docs/master/";
|
|
9
|
+
export declare const API_BASE = "https://api.github.com/repos/VKneider/slicejs_docs/contents/";
|
|
10
|
+
export interface DocItem {
|
|
11
|
+
id: string;
|
|
12
|
+
path: string;
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare let DOCS_STRUCTURE: DocItem[];
|
|
17
|
+
export declare let isInitialized: boolean;
|
|
18
|
+
export declare function initializeDocsStructure(): Promise<void>;
|
|
19
|
+
export declare function fetchDocContent(docId: string): Promise<string | null>;
|
|
20
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,KAAK;aAA8B,MAAM;eAAa,MAAM;EAAK,CAAC;AAC/E,eAAO,MAAM,SAAS,QAAW,CAAC;AAElC,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUpD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3D;AAED,eAAO,MAAM,QAAQ,oEAAoE,CAAC;AAC1F,eAAO,MAAM,QAAQ,iEAAiE,CAAC;AAEvF,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAGD,eAAO,IAAI,cAAc,EAAE,OAAO,EAAO,CAAC;AAC1C,eAAO,IAAI,aAAa,SAAQ,CAAC;AAiDjC,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAY7D;AAGD,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkB3E"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Cache implementation
|
|
2
|
+
export const cache = new Map();
|
|
3
|
+
export const CACHE_TTL = Infinity; // Never expire during session
|
|
4
|
+
export function getCached(key) {
|
|
5
|
+
const cached = cache.get(key);
|
|
6
|
+
if (!cached)
|
|
7
|
+
return null;
|
|
8
|
+
if (Date.now() - cached.timestamp > CACHE_TTL) {
|
|
9
|
+
cache.delete(key);
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return cached.content;
|
|
13
|
+
}
|
|
14
|
+
export function setCache(key, content) {
|
|
15
|
+
cache.set(key, { content, timestamp: Date.now() });
|
|
16
|
+
}
|
|
17
|
+
export const BASE_URL = 'https://raw.githubusercontent.com/VKneider/slicejs_docs/master/';
|
|
18
|
+
export const API_BASE = 'https://api.github.com/repos/VKneider/slicejs_docs/contents/';
|
|
19
|
+
// Global structure, populated dynamically
|
|
20
|
+
export let DOCS_STRUCTURE = [];
|
|
21
|
+
export let isInitialized = false;
|
|
22
|
+
// Function to fetch GitHub API for directory contents
|
|
23
|
+
async function fetchGitHubContents(path) {
|
|
24
|
+
const url = `${API_BASE}${path}`;
|
|
25
|
+
const response = await fetch(url);
|
|
26
|
+
if (!response.ok)
|
|
27
|
+
throw new Error(`GitHub API error: ${response.status}`);
|
|
28
|
+
return response.json();
|
|
29
|
+
}
|
|
30
|
+
// Recursive function to build DOCS_STRUCTURE
|
|
31
|
+
async function buildDocsStructure(dirPath, basePath = 'markdown') {
|
|
32
|
+
const items = [];
|
|
33
|
+
const contents = await fetchGitHubContents(dirPath);
|
|
34
|
+
for (const item of contents) {
|
|
35
|
+
if (item.type === 'file' && item.name.endsWith('.md') && item.name !== 'markdown-guide.md') {
|
|
36
|
+
// Fetch title from content
|
|
37
|
+
const rawUrl = `https://raw.githubusercontent.com/VKneider/slicejs_docs/master/${item.path}`;
|
|
38
|
+
let title = item.name.replace('.md', ''); // fallback
|
|
39
|
+
try {
|
|
40
|
+
const contentResponse = await fetch(rawUrl);
|
|
41
|
+
if (contentResponse.ok) {
|
|
42
|
+
const content = await contentResponse.text();
|
|
43
|
+
const titleMatch = content.split('\n').find(line => line.startsWith('# '));
|
|
44
|
+
if (titleMatch)
|
|
45
|
+
title = titleMatch.replace('# ', '');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.warn(`Failed to fetch title for ${item.path}:`, error);
|
|
50
|
+
}
|
|
51
|
+
const relativePath = item.path.replace(`${basePath}/`, '');
|
|
52
|
+
const id = relativePath.replace(/\.md$/, '').replace(/\//g, '/');
|
|
53
|
+
items.push({
|
|
54
|
+
id,
|
|
55
|
+
path: item.path,
|
|
56
|
+
title,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else if (item.type === 'dir') {
|
|
60
|
+
// Recurse into subdirs
|
|
61
|
+
const subItems = await buildDocsStructure(item.path, basePath);
|
|
62
|
+
items.push(...subItems);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return items;
|
|
66
|
+
}
|
|
67
|
+
// Initialize docs structure dynamically
|
|
68
|
+
export async function initializeDocsStructure() {
|
|
69
|
+
if (isInitialized)
|
|
70
|
+
return;
|
|
71
|
+
try {
|
|
72
|
+
DOCS_STRUCTURE = await buildDocsStructure('markdown');
|
|
73
|
+
isInitialized = true;
|
|
74
|
+
console.log(`Initialized docs structure with ${DOCS_STRUCTURE.length} documents`);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error('Failed to initialize docs structure:', error);
|
|
78
|
+
// Fallback to empty or hardcoded minimal
|
|
79
|
+
DOCS_STRUCTURE = [];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Helper function to fetch doc content from GitHub
|
|
83
|
+
export async function fetchDocContent(docId) {
|
|
84
|
+
const cached = getCached(docId);
|
|
85
|
+
if (cached)
|
|
86
|
+
return cached;
|
|
87
|
+
const doc = DOCS_STRUCTURE.find(d => d.id === docId);
|
|
88
|
+
if (!doc)
|
|
89
|
+
return null;
|
|
90
|
+
const url = `${BASE_URL}${doc.path}`;
|
|
91
|
+
try {
|
|
92
|
+
const response = await fetch(url);
|
|
93
|
+
if (!response.ok)
|
|
94
|
+
throw new Error(`HTTP ${response.status}`);
|
|
95
|
+
const content = await response.text();
|
|
96
|
+
setCache(docId, content);
|
|
97
|
+
return content;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error(`Error fetching ${url}:`, error);
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkD,CAAC;AAC/E,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,8BAA8B;AAEjE,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC;QAC9C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,OAAe;IACnD,KAAK,CAAC,GAAG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AC/C,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "slicejs-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for Slicejs documentation access",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"slicejs-mcp": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"prepare": "npm run build",
|
|
19
|
+
"start": "node dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"fastmcp": "^3.32.0",
|
|
23
|
+
"zod": "^3.24.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^22.10.5",
|
|
27
|
+
"typescript": "^5.7.3"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"mcp",
|
|
34
|
+
"slicejs",
|
|
35
|
+
"slice.js",
|
|
36
|
+
"documentation",
|
|
37
|
+
"slicejs-web-framework",
|
|
38
|
+
"llm"
|
|
39
|
+
]
|
|
40
|
+
}
|