astralis-mcp 0.2.0 → 0.3.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 +6 -4
- package/package.json +1 -1
- package/server.mjs +98 -2
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
MCP server for [Astralis UI](https://astralis-zeta.vercel.app) — lets AI
|
|
4
4
|
coding agents (Claude Code, Cursor, …) look up the library's **current**
|
|
5
|
-
component APIs, full props tables, runnable demo source
|
|
6
|
-
instead of guessing from training data.
|
|
5
|
+
component APIs, full props tables, runnable demo source, theming guides and
|
|
6
|
+
block sources instead of guessing from training data.
|
|
7
7
|
|
|
8
|
-
Reads the docs site's machine-readable endpoints
|
|
9
|
-
from what the documentation actually
|
|
8
|
+
Reads the docs site's machine-readable endpoints and its block registry, so
|
|
9
|
+
answers can never drift from what the documentation actually ships.
|
|
10
10
|
|
|
11
11
|
## Setup
|
|
12
12
|
|
|
@@ -37,6 +37,8 @@ No install step — `npx` fetches and runs it on demand.
|
|
|
37
37
|
| `get_guide` | A guide page: `installation`, `quick-start`, `theming`, `colors`, `responsive`, `style-props`, `tokens` |
|
|
38
38
|
| `search_docs` | Full-text search across everything, with snippets |
|
|
39
39
|
| `get_theming` | The complete theming + design-token reference in one call |
|
|
40
|
+
| `list_blocks` | Every block — prebuilt page sections — with id, description, category and the components it composes. Filterable by category |
|
|
41
|
+
| `get_block` | One block's metadata plus the complete source of its files, ready to write into a project |
|
|
40
42
|
|
|
41
43
|
## Options
|
|
42
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astralis-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
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
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/server.mjs
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* instead of hallucinated ones.
|
|
5
5
|
*
|
|
6
6
|
* Data source: the deployed docs site's machine-readable endpoints
|
|
7
|
-
* (/llms.txt, /docs/components/*.md, /docs/*.md)
|
|
8
|
-
*
|
|
7
|
+
* (/llms.txt, /docs/components/*.md, /docs/*.md) and its block registry
|
|
8
|
+
* (/r/index.json, /r/{id}.json) — the same single pipeline that renders the
|
|
9
|
+
* human docs, so answers can never drift from the site.
|
|
9
10
|
* Point ASTRALIS_DOCS_URL at a local dev server (http://localhost:3000)
|
|
10
11
|
* when working on unpublished docs.
|
|
11
12
|
*
|
|
@@ -76,6 +77,29 @@ async function listPages() {
|
|
|
76
77
|
return pages;
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
/**
|
|
81
|
+
* The block registry, served as static JSON by the same docs deploy
|
|
82
|
+
* (astralis-docs/scripts/gen-block-registry.mjs). Reusing fetchText means
|
|
83
|
+
* blocks get the same cache, timeout and local-dev override as the docs.
|
|
84
|
+
*/
|
|
85
|
+
async function fetchJson(path) {
|
|
86
|
+
return JSON.parse(await fetchText(path));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function blockCatalogue() {
|
|
90
|
+
return (await fetchJson("/r/index.json")).blocks;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** One registry item, source included. Null when the id is unknown. */
|
|
94
|
+
async function blockItem(id) {
|
|
95
|
+
if (!/^[a-z0-9-]+$/.test(id)) return null;
|
|
96
|
+
try {
|
|
97
|
+
return await fetchJson(`/r/${id}.json`);
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
79
103
|
async function pageMarkdown(slug, kind) {
|
|
80
104
|
if (!/^[a-z0-9-]+$/.test(slug)) return null;
|
|
81
105
|
try {
|
|
@@ -177,5 +201,77 @@ server.tool(
|
|
|
177
201
|
},
|
|
178
202
|
);
|
|
179
203
|
|
|
204
|
+
/* ---------- blocks ---------- */
|
|
205
|
+
|
|
206
|
+
server.tool(
|
|
207
|
+
"list_blocks",
|
|
208
|
+
"List every Astralis block — prebuilt page sections (hero, pricing, dashboard, login…) composed from Astralis UI components. Each entry has id, name, description, category and the components it composes. Call this first to discover valid block ids. Pass a category to narrow the list.",
|
|
209
|
+
{
|
|
210
|
+
category: z
|
|
211
|
+
.string()
|
|
212
|
+
.optional()
|
|
213
|
+
.describe("Optional filter, e.g. 'hero', 'pricing', 'dashboard', 'login'"),
|
|
214
|
+
},
|
|
215
|
+
async ({ category }) => {
|
|
216
|
+
try {
|
|
217
|
+
const blocks = await blockCatalogue();
|
|
218
|
+
if (!category) return asText(JSON.stringify(blocks, null, 2));
|
|
219
|
+
|
|
220
|
+
const wanted = category.toLowerCase();
|
|
221
|
+
const filtered = blocks.filter((b) => b.category === wanted);
|
|
222
|
+
if (filtered.length) return asText(JSON.stringify(filtered, null, 2));
|
|
223
|
+
|
|
224
|
+
const categories = [...new Set(blocks.map((b) => b.category))].sort();
|
|
225
|
+
return asError(`No blocks in category "${category}". Categories: ${categories.join(", ")}.`);
|
|
226
|
+
} catch (err) {
|
|
227
|
+
return offline(err);
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
server.tool(
|
|
233
|
+
"get_block",
|
|
234
|
+
"One Astralis block: its metadata plus the complete source of every file it contains, ready to write into a project. A block depends only on astralis-ui — no other packages, no Tailwind config, no per-block setup. Use an id from list_blocks.",
|
|
235
|
+
{ id: z.string().describe("Block id, e.g. 'hero-01', 'pricing-02', 'dashboard-03'") },
|
|
236
|
+
async ({ id }) => {
|
|
237
|
+
try {
|
|
238
|
+
const block = await blockItem(id);
|
|
239
|
+
if (!block) {
|
|
240
|
+
const ids = (await blockCatalogue()).map((b) => b.id);
|
|
241
|
+
return asError(`Unknown block "${id}". Valid ids: ${ids.join(", ")}.`);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/*
|
|
245
|
+
* Markdown rather than raw JSON: the payload is mostly source code, and
|
|
246
|
+
* fenced blocks keep an agent from having to unescape a JSON string
|
|
247
|
+
* before it can write the file.
|
|
248
|
+
*/
|
|
249
|
+
const sections = [
|
|
250
|
+
`# ${block.name}`,
|
|
251
|
+
"",
|
|
252
|
+
block.description,
|
|
253
|
+
"",
|
|
254
|
+
`- **id** \`${block.id}\` · **category** \`${block.category}\``,
|
|
255
|
+
`- **exports** \`${block.component}\``,
|
|
256
|
+
`- **composes** ${block.uses.map((u) => `\`${u}\``).join(", ")}`,
|
|
257
|
+
`- **preview** ${SITE}/blocks/${block.id}`,
|
|
258
|
+
"",
|
|
259
|
+
`Install with \`astralis add ${block.id}\`, or write the files below yourself —`,
|
|
260
|
+
`they belong to the project once copied. The only dependency is \`astralis-ui\`.`,
|
|
261
|
+
"",
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
for (const file of block.contents) {
|
|
265
|
+
const lang = file.path.endsWith(".tsx") || file.path.endsWith(".ts") ? "tsx" : "";
|
|
266
|
+
sections.push(`## ${file.path}`, "", `\`\`\`${lang}`, file.content.trimEnd(), "```", "");
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return asText(sections.join("\n"));
|
|
270
|
+
} catch (err) {
|
|
271
|
+
return offline(err);
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
);
|
|
275
|
+
|
|
180
276
|
const transport = new StdioServerTransport();
|
|
181
277
|
await server.connect(transport);
|