astralis-mcp 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 +49 -0
- package/package.json +43 -0
- package/server.mjs +157 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# astralis-mcp
|
|
2
|
+
|
|
3
|
+
MCP server for [Astralis UI](https://astralis-zeta.vercel.app) — lets AI
|
|
4
|
+
coding agents (Claude Code, Cursor, …) look up the library's **current**
|
|
5
|
+
component APIs, full props tables, runnable demo source and theming guides
|
|
6
|
+
instead of guessing from training data.
|
|
7
|
+
|
|
8
|
+
Reads the docs site's machine-readable endpoints, so answers can never drift
|
|
9
|
+
from what the documentation actually says.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
**Claude Code:**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
claude mcp add astralis -- npx -y astralis-mcp
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Any MCP client**, in its config:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"astralis": { "command": "npx", "args": ["-y", "astralis-mcp"] }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
No install step — `npx` fetches and runs it on demand.
|
|
30
|
+
|
|
31
|
+
## Tools
|
|
32
|
+
|
|
33
|
+
| Tool | What it returns |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| `list_components` | Every docs page — 62 components + 7 guides — with slug, description, category |
|
|
36
|
+
| `get_component` | One component's full docs: props table, keyboard map, a11y notes, demo source |
|
|
37
|
+
| `get_guide` | A guide page: `installation`, `quick-start`, `theming`, `colors`, `responsive`, `style-props`, `tokens` |
|
|
38
|
+
| `search_docs` | Full-text search across everything, with snippets |
|
|
39
|
+
| `get_theming` | The complete theming + design-token reference in one call |
|
|
40
|
+
|
|
41
|
+
## Options
|
|
42
|
+
|
|
43
|
+
| Env var | Default | Purpose |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `ASTRALIS_DOCS_URL` | `https://astralis-zeta.vercel.app` | Point at a local docs dev server (`http://localhost:3000`) when working on unpublished docs |
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT © Paul Andrew
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "astralis-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server exposing Astralis UI docs to AI coding agents — current component APIs, props tables, demo sources, and theming guides instead of hallucinated ones.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Paul Andrew",
|
|
8
|
+
"homepage": "https://astralis-zeta.vercel.app",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/SekiroDev360/astralis-ui.git",
|
|
12
|
+
"directory": "packages/astralis-mcp"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/SekiroDev360/astralis-ui/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"astralis-ui",
|
|
21
|
+
"react",
|
|
22
|
+
"components",
|
|
23
|
+
"ai",
|
|
24
|
+
"claude",
|
|
25
|
+
"documentation"
|
|
26
|
+
],
|
|
27
|
+
"bin": {
|
|
28
|
+
"astralis-mcp": "server.mjs"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"server.mjs"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"start": "node server.mjs"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
41
|
+
"zod": "^3.23.0"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/server.mjs
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Astralis UI MCP server — gives AI coding agents current component APIs
|
|
4
|
+
* instead of hallucinated ones.
|
|
5
|
+
*
|
|
6
|
+
* Data source: the deployed docs site's machine-readable endpoints
|
|
7
|
+
* (/llms.txt, /docs/components/*.md, /docs/*.md) — the same single pipeline
|
|
8
|
+
* that renders the human docs, so answers can never drift from the site.
|
|
9
|
+
* Point ASTRALIS_DOCS_URL at a local dev server (http://localhost:3000)
|
|
10
|
+
* when working on unpublished docs.
|
|
11
|
+
*
|
|
12
|
+
* Register in an MCP client:
|
|
13
|
+
* { "command": "npx", "args": ["-y", "astralis-mcp"] }
|
|
14
|
+
*/
|
|
15
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
16
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
|
|
19
|
+
const SITE = (process.env.ASTRALIS_DOCS_URL ?? "https://astralis-zeta.vercel.app").replace(/\/$/, "");
|
|
20
|
+
|
|
21
|
+
/* ---------- data: fetched once per process, then cached ---------- */
|
|
22
|
+
|
|
23
|
+
const cache = new Map();
|
|
24
|
+
|
|
25
|
+
async function fetchText(path) {
|
|
26
|
+
if (cache.has(path)) return cache.get(path);
|
|
27
|
+
const res = await fetch(`${SITE}${path}`);
|
|
28
|
+
if (!res.ok) throw new Error(`${res.status} for ${SITE}${path}`);
|
|
29
|
+
const text = await res.text();
|
|
30
|
+
cache.set(path, text);
|
|
31
|
+
return text;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Parse llms.txt into [{slug, title, description, section, kind}]. */
|
|
35
|
+
async function listPages() {
|
|
36
|
+
const index = await fetchText("/llms.txt");
|
|
37
|
+
const pages = [];
|
|
38
|
+
let section = "";
|
|
39
|
+
for (const line of index.split("\n")) {
|
|
40
|
+
const heading = line.match(/^## (.+)$/);
|
|
41
|
+
if (heading) section = heading[1];
|
|
42
|
+
const item = line.match(/^- \[([^\]]+)\]\(\S*\/docs\/(?:(components)\/)?([a-z0-9-]+)\.md\):\s*(.*)$/);
|
|
43
|
+
if (!item) continue;
|
|
44
|
+
pages.push({
|
|
45
|
+
slug: item[3],
|
|
46
|
+
title: item[1],
|
|
47
|
+
description: item[4],
|
|
48
|
+
section,
|
|
49
|
+
kind: item[2] ? "component" : "guide",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return pages;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function pageMarkdown(slug, kind) {
|
|
56
|
+
if (!/^[a-z0-9-]+$/.test(slug)) return null;
|
|
57
|
+
try {
|
|
58
|
+
return await fetchText(kind === "guide" ? `/docs/${slug}.md` : `/docs/components/${slug}.md`);
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const asText = (text) => ({ content: [{ type: "text", text }] });
|
|
65
|
+
const asError = (text) => ({ content: [{ type: "text", text }], isError: true });
|
|
66
|
+
const offline = (err) =>
|
|
67
|
+
asError(`Could not reach the Astralis docs at ${SITE} (${err.message}). Check your connection, or set ASTRALIS_DOCS_URL.`);
|
|
68
|
+
|
|
69
|
+
/* ---------- server ---------- */
|
|
70
|
+
|
|
71
|
+
const server = new McpServer({ name: "astralis-ui", version: "0.2.0" });
|
|
72
|
+
|
|
73
|
+
server.tool(
|
|
74
|
+
"list_components",
|
|
75
|
+
"List every Astralis UI docs page — all 62 components plus the guides (installation, theming, colors, responsive props, style props, design tokens) — with slug, one-line description, category, and kind (component | guide).",
|
|
76
|
+
{},
|
|
77
|
+
async () => {
|
|
78
|
+
try {
|
|
79
|
+
return asText(JSON.stringify(await listPages(), null, 2));
|
|
80
|
+
} catch (err) {
|
|
81
|
+
return offline(err);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
server.tool(
|
|
87
|
+
"get_component",
|
|
88
|
+
"Full documentation for one component as markdown: usage, complete props table, keyboard/accessibility notes, and runnable demo source code. Use the slug from list_components.",
|
|
89
|
+
{ slug: z.string().describe("Component docs slug, e.g. 'button', 'number-input'") },
|
|
90
|
+
async ({ slug }) => {
|
|
91
|
+
try {
|
|
92
|
+
const md = await pageMarkdown(slug, "component");
|
|
93
|
+
return md
|
|
94
|
+
? asText(md)
|
|
95
|
+
: asError(`Unknown component "${slug}". Call list_components for valid slugs.`);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
return offline(err);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
server.tool(
|
|
103
|
+
"get_guide",
|
|
104
|
+
"One of the Astralis guide pages as markdown: installation, quick-start, theming, colors, responsive, style-props, or tokens.",
|
|
105
|
+
{ slug: z.string().describe("Guide slug, e.g. 'installation', 'theming', 'tokens'") },
|
|
106
|
+
async ({ slug }) => {
|
|
107
|
+
try {
|
|
108
|
+
const md = await pageMarkdown(slug, "guide");
|
|
109
|
+
return md
|
|
110
|
+
? asText(md)
|
|
111
|
+
: asError(`Unknown guide "${slug}". Valid: installation, quick-start, theming, colors, responsive, style-props, tokens.`);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
return offline(err);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
server.tool(
|
|
119
|
+
"search_docs",
|
|
120
|
+
"Full-text search across all Astralis documentation (guides + components). Returns matching pages with a snippet around the first hit.",
|
|
121
|
+
{ query: z.string().describe("Search text, e.g. 'focus trap' or 'aria-describedby'") },
|
|
122
|
+
async ({ query }) => {
|
|
123
|
+
try {
|
|
124
|
+
const q = query.toLowerCase();
|
|
125
|
+
const hits = [];
|
|
126
|
+
for (const page of await listPages()) {
|
|
127
|
+
const md = (await pageMarkdown(page.slug, page.kind)) ?? "";
|
|
128
|
+
const idx = md.toLowerCase().indexOf(q);
|
|
129
|
+
if (idx === -1) continue;
|
|
130
|
+
hits.push({ ...page, snippet: md.slice(Math.max(0, idx - 80), idx + 120).replace(/\s+/g, " ") });
|
|
131
|
+
}
|
|
132
|
+
return asText(hits.length ? JSON.stringify(hits, null, 2) : "No matches.");
|
|
133
|
+
} catch (err) {
|
|
134
|
+
return offline(err);
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
server.tool(
|
|
140
|
+
"get_theming",
|
|
141
|
+
"The complete Astralis theming reference: the token system, dark mode, runtime brand color, colorScheme/accent channel, plus every design-token scale (spacing, sizing, type, radius, shadows, motion).",
|
|
142
|
+
{},
|
|
143
|
+
async () => {
|
|
144
|
+
try {
|
|
145
|
+
const [theming, tokens] = await Promise.all([
|
|
146
|
+
pageMarkdown("theming", "guide"),
|
|
147
|
+
pageMarkdown("tokens", "guide"),
|
|
148
|
+
]);
|
|
149
|
+
return asText([theming ?? "", "\n---\n", tokens ?? ""].join("\n"));
|
|
150
|
+
} catch (err) {
|
|
151
|
+
return offline(err);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const transport = new StdioServerTransport();
|
|
157
|
+
await server.connect(transport);
|