@wattsonme/codexlib 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/index.js +52 -0
- package/package.json +12 -0
package/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { Server } = require("@modelcontextprotocol/sdk/server/index.js");
|
|
3
|
+
const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
4
|
+
|
|
5
|
+
const API = "https://codexlib.io/api";
|
|
6
|
+
|
|
7
|
+
async function api(path) {
|
|
8
|
+
const res = await fetch(`${API}${path}`);
|
|
9
|
+
return res.json();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const server = new Server({ name: "codexlib", version: "1.0.0" }, {
|
|
13
|
+
capabilities: { tools: {} }
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
server.setRequestHandler({ method: "tools/list" }, async () => ({
|
|
17
|
+
tools: [
|
|
18
|
+
{ name: "codexlib_search", description: "Search CodexLib for knowledge packs by topic. Returns matching packs with previews.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Topic to search for (e.g. 'kubernetes', 'islam', 'react hooks')" }, limit: { type: "number", description: "Max results (default 5)" } }, required: ["query"] } },
|
|
19
|
+
{ name: "codexlib_pull", description: "Pull a full knowledge pack into your context. Returns compressed expert knowledge with rosetta decoder.", inputSchema: { type: "object", properties: { slug: { type: "string", description: "Pack slug (e.g. 'react-hooks-patterns', 'islam-fiqh-jurisprudence')" } }, required: ["slug"] } },
|
|
20
|
+
{ name: "codexlib_domains", description: "List all available knowledge domains and pack counts.", inputSchema: { type: "object", properties: {} } },
|
|
21
|
+
{ name: "codexlib_stats", description: "Get CodexLib statistics — total packs, domains, latest additions.", inputSchema: { type: "object", properties: {} } },
|
|
22
|
+
]
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
server.setRequestHandler({ method: "tools/call" }, async (req) => {
|
|
26
|
+
const { name, arguments: args } = req.params;
|
|
27
|
+
try {
|
|
28
|
+
let result;
|
|
29
|
+
switch (name) {
|
|
30
|
+
case "codexlib_search":
|
|
31
|
+
result = await api(`/packs/search?q=${encodeURIComponent(args.query)}&limit=${args.limit || 5}`);
|
|
32
|
+
break;
|
|
33
|
+
case "codexlib_pull":
|
|
34
|
+
result = await api(`/packs/${args.slug}`);
|
|
35
|
+
break;
|
|
36
|
+
case "codexlib_domains":
|
|
37
|
+
result = await api("/domains");
|
|
38
|
+
break;
|
|
39
|
+
case "codexlib_stats":
|
|
40
|
+
result = await api("/stats");
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
result = { error: "Unknown tool" };
|
|
44
|
+
}
|
|
45
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return { content: [{ type: "text", text: `Error: ${e.message}` }], isError: true };
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const transport = new StdioServerTransport();
|
|
52
|
+
server.connect(transport);
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wattsonme/codexlib",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Pull expert AI knowledge packs into your context window. 419+ packs across religion, AI, science, business, and more.",
|
|
5
|
+
"bin": { "codexlib-mcp": "./index.js" },
|
|
6
|
+
"keywords": ["mcp", "knowledge", "ai", "codex", "packs", "context", "compression", "tokenshrink"],
|
|
7
|
+
"author": "chatde",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": { "type": "git", "url": "https://github.com/chatde/codexlib" },
|
|
10
|
+
"homepage": "https://codexlib.io",
|
|
11
|
+
"dependencies": { "@modelcontextprotocol/sdk": "^1.0.0" }
|
|
12
|
+
}
|