starlight-mcp 0.1.0 → 0.2.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 CHANGED
@@ -149,7 +149,7 @@ All options are optional.
149
149
  | `include` | all | Only index docs whose id starts with one of these prefixes |
150
150
  | `exclude` | none | Drop docs whose id starts with one of these prefixes |
151
151
  | `docsRedirect` | — | 302 humans who open the endpoint in a browser to this page (otherwise: a polite 405 JSON explainer) |
152
- | `toolDescriptions` | generated | Replace the description of any tool, e.g. `{ search_docs: "Search the Acme docs (billing, webhooks, SDKs)…" }` — worth hand-tuning so agents know when to reach for it |
152
+ | `toolDescriptions` | generated | Replace the description of any tool, e.g. `{ search_docs: "Search the Acme docs (billing, webhooks, SDKs)…" }` — worth hand-tuning so agents know when to reach for it. Object form also overrides argument descriptions: `{ search_docs: { description: "…", args: { query: "e.g. 'webhook retries'" } } }` |
153
153
 
154
154
  MDX noise (import statements, standalone `<Component>` tag lines) is stripped from indexed bodies automatically.
155
155
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Give your Astro or Starlight docs site an MCP server — search_docs, get_doc and list_docs over stateless streamable HTTP. Astro integration, pure fetch handler, and Cloudflare static-assets glue included.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/tools.ts CHANGED
@@ -8,19 +8,42 @@ export interface McpTool {
8
8
  inputSchema: Record<string, unknown>;
9
9
  }
10
10
 
11
+ /**
12
+ * Override a tool's description with a plain string, or use the object
13
+ * form to also replace argument descriptions inside its inputSchema:
14
+ * `{ search_docs: { description: "…", args: { query: "…" } } }`.
15
+ */
16
+ export type ToolOverride =
17
+ | string
18
+ | { description?: string; args?: Record<string, string> };
19
+
11
20
  export type ToolDescriptions = Partial<
12
- Record<"search_docs" | "get_doc" | "list_docs", string>
21
+ Record<"search_docs" | "get_doc" | "list_docs", ToolOverride>
13
22
  >;
14
23
 
24
+ const overrideDescription = (override: ToolOverride | undefined) =>
25
+ typeof override === "string" ? override : override?.description;
26
+
27
+ function applyArgOverrides(tool: McpTool, override: ToolOverride | undefined): McpTool {
28
+ if (typeof override !== "object" || !override.args) return tool;
29
+ const properties = {
30
+ ...(tool.inputSchema.properties as Record<string, Record<string, unknown>>),
31
+ };
32
+ for (const [arg, description] of Object.entries(override.args)) {
33
+ if (properties[arg]) properties[arg] = { ...properties[arg], description };
34
+ }
35
+ return { ...tool, inputSchema: { ...tool.inputSchema, properties } };
36
+ }
37
+
15
38
  export function makeTools(
16
39
  siteLabel: string,
17
40
  overrides: ToolDescriptions = {},
18
41
  ): McpTool[] {
19
- return [
42
+ const tools: McpTool[] = [
20
43
  {
21
44
  name: "search_docs",
22
45
  description:
23
- overrides.search_docs ??
46
+ overrideDescription(overrides.search_docs) ??
24
47
  `Search the ${siteLabel} documentation. Returns the best-matching pages with snippets and URLs.`,
25
48
  inputSchema: {
26
49
  type: "object",
@@ -36,7 +59,7 @@ export function makeTools(
36
59
  {
37
60
  name: "get_doc",
38
61
  description:
39
- overrides.get_doc ??
62
+ overrideDescription(overrides.get_doc) ??
40
63
  "Fetch one documentation page as full markdown by its path (as returned by search_docs or list_docs).",
41
64
  inputSchema: {
42
65
  type: "object",
@@ -49,9 +72,12 @@ export function makeTools(
49
72
  {
50
73
  name: "list_docs",
51
74
  description:
52
- overrides.list_docs ??
75
+ overrideDescription(overrides.list_docs) ??
53
76
  "List every documentation page with its title, description and URL.",
54
77
  inputSchema: { type: "object", properties: {} },
55
78
  },
56
79
  ];
80
+ return tools.map((tool) =>
81
+ applyArgOverrides(tool, overrides[tool.name as keyof ToolDescriptions]),
82
+ );
57
83
  }