mcp-ts-transcript 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/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # mcp-ts-transcript
2
+
3
+ MCP server with a single tool that compiles TypeScript code to JavaScript using the TypeScript compiler API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npx mcp-ts-transcript
9
+ ```
10
+
11
+ ## Usage with Claude Code
12
+
13
+ ```bash
14
+ claude mcp add -s user ts-transcript npx mcp-ts-transcript
15
+ ```
16
+
17
+ ## Tool
18
+
19
+ ### `compile_typescript`
20
+
21
+ Receives TypeScript source code and returns the compiled JavaScript.
22
+
23
+ **Input**
24
+
25
+ | Parameter | Type | Required | Description |
26
+ |-----------|--------|----------|---------------------------|
27
+ | `code` | string | yes | TypeScript code to compile |
28
+
29
+ **Output**
30
+
31
+ Returns the compiled JavaScript as plain text. If the compilation fails, returns the error message with `isError: true`.
32
+
33
+ **Example**
34
+
35
+ Input:
36
+ ```typescript
37
+ const greet = (name: string): string => `Hello, ${name}!`;
38
+ console.log(greet("World"));
39
+ ```
40
+
41
+ Output:
42
+ ```javascript
43
+ const greet = (name) => `Hello, ${name}!`;
44
+ console.log(greet("World"));
45
+ ```
46
+
47
+ ## Compiler options
48
+
49
+ Compiled with the following fixed options:
50
+
51
+ - `target`: ES2020
52
+ - `module`: CommonJS
53
+ - `esModuleInterop`: true
54
+ - `strict`: false
55
+
56
+ ## Development
57
+
58
+ ```bash
59
+ npm install
60
+ npm run build
61
+ npm start
62
+ ```
63
+
64
+ ## License
65
+
66
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,54 @@
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 * as ts from "typescript";
6
+ const server = new Server({ name: "ts-transcript", version: "1.0.0" }, { capabilities: { tools: {} } });
7
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
8
+ tools: [
9
+ {
10
+ name: "compile_typescript",
11
+ description: "Receives TypeScript code, compiles it and returns the JavaScript output.",
12
+ inputSchema: {
13
+ type: "object",
14
+ properties: {
15
+ code: {
16
+ type: "string",
17
+ description: "TypeScript source code to compile",
18
+ },
19
+ },
20
+ required: ["code"],
21
+ },
22
+ },
23
+ ],
24
+ }));
25
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
26
+ if (request.params.name !== "compile_typescript") {
27
+ throw new Error(`Unknown tool: ${request.params.name}`);
28
+ }
29
+ const { code } = request.params.arguments;
30
+ const result = ts.transpileModule(code, {
31
+ compilerOptions: {
32
+ target: ts.ScriptTarget.ES2020,
33
+ module: ts.ModuleKind.CommonJS,
34
+ esModuleInterop: true,
35
+ strict: false,
36
+ },
37
+ reportDiagnostics: true,
38
+ });
39
+ if (result.diagnostics && result.diagnostics.length > 0) {
40
+ const errors = result.diagnostics
41
+ .map((d) => ts.flattenDiagnosticMessageText(d.messageText, "\n"))
42
+ .join("\n");
43
+ return {
44
+ content: [{ type: "text", text: `Compilation errors:\n${errors}` }],
45
+ isError: true,
46
+ };
47
+ }
48
+ return {
49
+ content: [{ type: "text", text: result.outputText }],
50
+ };
51
+ });
52
+ const transport = new StdioServerTransport();
53
+ await server.connect(transport);
54
+ console.error("ts-transcript MCP running on stdio");
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "mcp-ts-transcript",
3
+ "version": "1.0.0",
4
+ "description": "MCP server that compiles TypeScript code to JavaScript",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "mcp-ts-transcript": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "prepare": "npm run build",
16
+ "start": "node dist/index.js"
17
+ },
18
+ "keywords": ["mcp", "typescript", "compiler"],
19
+ "author": "Confience",
20
+ "license": "MIT",
21
+ "dependencies": {
22
+ "@modelcontextprotocol/sdk": "^1.29.0",
23
+ "typescript": "^5.9.3"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^22.0.0"
27
+ },
28
+ "engines": {
29
+ "node": ">=18"
30
+ }
31
+ }