@thotyo/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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thotyo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Thotyo MCP Server
2
+
3
+ Thotyo is a machine-facing documentation infrastructure for AI agents. This MCP (Model Context Protocol) server acts as an adapter to access Thotyo's canonical, versioned documentation via a simple tool interface.
4
+
5
+ ## Installation
6
+
7
+ ### Global Installation
8
+ ```bash
9
+ npm install -g @thotyo/mcp
10
+ ```
11
+
12
+ ### Usage with npx
13
+ ```bash
14
+ npx @thotyo/mcp
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ The server requires an API key from Thotyo to function.
20
+
21
+ ### Environment Variables
22
+
23
+ | Variable | Description | Default |
24
+ |----------|-------------|---------|
25
+ | `THOTYO_API_KEY` | **Required**. Your Thotyo API key. | None |
26
+ | `THOTYO_API_BASE_URL` | Base URL of the Thotyo API. | `https://www.thotyo.com` |
27
+
28
+ ## Integration
29
+
30
+ ### Gemini CLI
31
+
32
+ To use this server with the Gemini CLI, add it to your `mcpServers` configuration (usually in `~/.gemini/config.json` or equivalent):
33
+
34
+ ```json
35
+ {
36
+ "mcpServers": {
37
+ "thotyo": {
38
+ "command": "npx",
39
+ "args": ["-y", "@thotyo/mcp"],
40
+ "env": {
41
+ "THOTYO_API_KEY": "your_api_key_here",
42
+ "THOTYO_API_BASE_URL": "https://www.thotyo.com"
43
+ }
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ ### GitHub Copilot
50
+
51
+ If your environment supports MCP (like some editor extensions), you can configure the Thotyo MCP server using the `stdio` transport.
52
+
53
+ If GitHub Copilot does not yet natively support MCP in your specific IDE version, you can:
54
+ 1. Use an MCP-to-HTTP gateway.
55
+ 2. Use the Thotyo API directly via HTTP if your Copilot setup allows custom skills/extensions.
56
+ 3. Use a compatible MCP host that bridges to Copilot.
57
+
58
+ ## Tools
59
+
60
+ ### `get_symbol`
61
+ Retrieve documentation for a specific symbol in a library version.
62
+
63
+ **Arguments:**
64
+ - `project` (string): The project or library name (e.g., 'node').
65
+ - `version` (string): The version string (e.g., '22.0').
66
+ - `symbol_id` (string): The unique identifier for the symbol (e.g., 'array-prototype-foreach').
67
+
68
+ ### `resolve_symbol`
69
+ Resolve a free-text query to a canonical `symbol_id` for a library version.
70
+
71
+ **Arguments:**
72
+ - `query` (string): The free-text query (e.g., 'foreach', 'array.map').
73
+ - `project` (string): The project or library name (e.g., 'node').
74
+ - `version` (string): The version string (e.g., '22.0').
75
+ - `limit` (number, optional): Optional limit for number of candidates (default 5, max 10).
76
+
77
+ ## Error Handling
78
+
79
+ The server returns structured error objects:
80
+ - `{ error: "missing_api_key" }`: API key not provided.
81
+ - `{ error: "unauthorized" }`: Invalid API key.
82
+ - `{ error: "rate_limited" }`: Too many requests.
83
+ - `{ error: "not_found" }`: Symbol or project not found.
84
+ - `{ error: "upstream_error" }`: Other errors from the Thotyo API.
85
+
86
+ ## License
87
+ MIT
package/dist/server.js ADDED
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
+ import { z } from "zod";
6
+ import { fetchSymbol, resolveSymbol } from "./thotyoClient.js";
7
+ const server = new Server({
8
+ name: "thotyo-mcp-server",
9
+ version: "1.0.0",
10
+ }, {
11
+ capabilities: {
12
+ tools: {},
13
+ },
14
+ });
15
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
16
+ return {
17
+ tools: [
18
+ {
19
+ name: "get_symbol",
20
+ description: "Retrieve documentation for a specific symbol in a library version",
21
+ inputSchema: {
22
+ type: "object",
23
+ properties: {
24
+ project: {
25
+ type: "string",
26
+ description: "The project or library name (e.g., 'node')",
27
+ },
28
+ version: {
29
+ type: "string",
30
+ description: "The version string (e.g., '22.0')",
31
+ },
32
+ symbol_id: {
33
+ type: "string",
34
+ description: "The unique identifier for the symbol (e.g., 'array-prototype-foreach')",
35
+ },
36
+ },
37
+ required: ["project", "version", "symbol_id"],
38
+ },
39
+ },
40
+ {
41
+ name: "resolve_symbol",
42
+ description: "Resolve a free-text query to a canonical symbol_id for a library version",
43
+ inputSchema: {
44
+ type: "object",
45
+ properties: {
46
+ query: {
47
+ type: "string",
48
+ description: "The free-text query (e.g., 'foreach', 'array.map')",
49
+ },
50
+ project: {
51
+ type: "string",
52
+ description: "The project or library name (e.g., 'node')",
53
+ },
54
+ version: {
55
+ type: "string",
56
+ description: "The version string (e.g., '22.0')",
57
+ },
58
+ limit: {
59
+ type: "number",
60
+ description: "Optional limit for number of candidates (default 5, max 10)",
61
+ },
62
+ },
63
+ required: ["query", "project", "version"],
64
+ },
65
+ },
66
+ ],
67
+ };
68
+ });
69
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
70
+ if (request.params.name === "get_symbol") {
71
+ const args = request.params.arguments;
72
+ const schema = z.object({
73
+ project: z.string(),
74
+ version: z.string(),
75
+ symbol_id: z.string(),
76
+ });
77
+ const parseResult = schema.safeParse(args);
78
+ if (!parseResult.success) {
79
+ throw new Error(`Invalid arguments: ${parseResult.error.message}`);
80
+ }
81
+ const { project, version, symbol_id } = parseResult.data;
82
+ const result = await fetchSymbol(project, version, symbol_id);
83
+ return {
84
+ content: [
85
+ {
86
+ type: "text",
87
+ text: JSON.stringify(result, null, 2),
88
+ },
89
+ ],
90
+ isError: "error" in result && result.error !== undefined,
91
+ };
92
+ }
93
+ if (request.params.name === "resolve_symbol") {
94
+ const args = request.params.arguments;
95
+ const schema = z.object({
96
+ query: z.string(),
97
+ project: z.string(),
98
+ version: z.string(),
99
+ limit: z.number().optional(),
100
+ });
101
+ const parseResult = schema.safeParse(args);
102
+ if (!parseResult.success) {
103
+ throw new Error(`Invalid arguments: ${parseResult.error.message}`);
104
+ }
105
+ const { query, project, version, limit } = parseResult.data;
106
+ const result = await resolveSymbol(query, project, version, limit);
107
+ return {
108
+ content: [
109
+ {
110
+ type: "text",
111
+ text: JSON.stringify(result, null, 2),
112
+ },
113
+ ],
114
+ isError: "error" in result && result.error !== undefined,
115
+ };
116
+ }
117
+ throw new Error(`Tool not found: ${request.params.name}`);
118
+ });
119
+ async function run() {
120
+ if (!process.env.THOTYO_API_KEY) {
121
+ console.error("Warning: THOTYO_API_KEY environment variable is not set. Tool calls will return an error.");
122
+ }
123
+ const transport = new StdioServerTransport();
124
+ await server.connect(transport);
125
+ console.error("Thotyo MCP Server running on STDIO");
126
+ }
127
+ run().catch((error) => {
128
+ console.error("Fatal error in main loop:", error);
129
+ process.exit(1);
130
+ });
@@ -0,0 +1,54 @@
1
+ const BASE_URL = process.env.THOTYO_API_BASE_URL || "https://www.thotyo.com";
2
+ const API_KEY = process.env.THOTYO_API_KEY;
3
+ async function request(path, params) {
4
+ if (!API_KEY) {
5
+ return { error: "missing_api_key" };
6
+ }
7
+ const url = `${BASE_URL}${path}${params ? `?${params.toString()}` : ""}`;
8
+ try {
9
+ const response = await fetch(url, {
10
+ method: "GET",
11
+ headers: {
12
+ "Accept": "application/json",
13
+ "X-API-Key": API_KEY,
14
+ },
15
+ });
16
+ if (response.ok) {
17
+ return (await response.json());
18
+ }
19
+ if (response.status === 401 || response.status === 403) {
20
+ return { error: "unauthorized", status: response.status };
21
+ }
22
+ if (response.status === 429) {
23
+ return { error: "rate_limited", status: 429 };
24
+ }
25
+ if (response.status === 404) {
26
+ return { error: "not_found", status: 404 };
27
+ }
28
+ return {
29
+ error: "upstream_error",
30
+ status: response.status,
31
+ message: response.statusText,
32
+ };
33
+ }
34
+ catch (error) {
35
+ return {
36
+ error: "upstream_error",
37
+ message: error instanceof Error ? error.message : String(error),
38
+ };
39
+ }
40
+ }
41
+ export async function fetchSymbol(project, version, symbolId) {
42
+ return request(`/api/symbols/${encodeURIComponent(project)}/${encodeURIComponent(version)}/${encodeURIComponent(symbolId)}`);
43
+ }
44
+ export async function resolveSymbol(query, project, version, limit) {
45
+ const params = new URLSearchParams({
46
+ q: query,
47
+ project,
48
+ version,
49
+ });
50
+ if (limit) {
51
+ params.append("limit", limit.toString());
52
+ }
53
+ return request("/api/resolve", params);
54
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@thotyo/mcp",
3
+ "version": "1.0.0",
4
+ "description": "Thotyo MCP server - Machine-facing documentation infrastructure for AI agents",
5
+ "type": "module",
6
+ "bin": {
7
+ "thotyo-mcp": "./dist/server.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "scripts": {
15
+ "dev": "tsx src/server.ts",
16
+ "build": "tsc && chmod +x dist/server.js",
17
+ "start": "node dist/server.js",
18
+ "prepublishOnly": "npm run build"
19
+ },
20
+ "dependencies": {
21
+ "@modelcontextprotocol/sdk": "^1.0.1",
22
+ "zod": "^3.23.8"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^20.0.0",
26
+ "tsx": "^4.0.0",
27
+ "typescript": "^5.0.0"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
32
+ }