|
1 | 1 | # ReScript MCP Server
|
2 | 2 |
|
3 |
| -A Model Context Protocol (MCP) server that provides comprehensive ReScript language support. This server exposes ReScript compiler analysis capabilities through MCP tools, enabling AI assistants to understand and work with ReScript code. |
4 |
| - |
5 |
| -## Features |
6 |
| - |
7 |
| -This MCP server provides the following tools: |
8 |
| - |
9 |
| -### Core Analysis Tools |
10 |
| - |
11 |
| -- **`context`** - Get type information and context for any position in a ReScript file |
12 |
| -- **`bindings`** - Find available bindings and completions at a specific location |
13 |
| -- **`find_definition`** - Navigate to the definition of a symbol |
14 |
| -- **`find_type_definition`** - Navigate to the type definition of a symbol |
15 |
| -- **`find_references`** - Find all references to a symbol |
16 |
| - |
17 |
| -### Code Quality Tools |
18 |
| - |
19 |
| -- **`document_symbols`** - Get all symbols declared in a ReScript file |
20 |
| -- **`format_file`** - Format a ReScript file according to standard conventions |
21 |
| -- **`syntax_diagnostics`** - Get syntax error diagnostics for a file |
22 |
| -- **`inlay_hints`** - Get type hints for a range of code |
23 |
| -- **`signature_help`** - Get function signature help at a specific location |
24 |
| - |
25 |
| -## Prerequisites |
26 |
| - |
27 |
| -- ReScript compiler and analysis tools must be installed and available in PATH |
28 |
| -- The `rescript-editor-analysis.exe` binary must be accessible |
29 |
| - |
30 |
| -## Installation |
31 |
| - |
32 |
| -```bash |
33 |
| -npm install |
34 |
| -npm run build |
35 |
| -``` |
36 |
| - |
37 |
| -## Usage |
38 |
| - |
39 |
| -This is an MCP server designed to be used with MCP clients. To use it with an AI assistant: |
40 |
| - |
41 |
| -1. Build the server: `npm run build` |
42 |
| -2. Configure your MCP client to use this server |
43 |
| -3. The server will be available at the built `dist/server.js` |
44 |
| - |
45 |
| -## Tool Examples |
46 |
| - |
47 |
| -### Get type information at a position |
48 |
| - |
49 |
| -```json |
50 |
| -{ |
51 |
| - "tool": "context", |
52 |
| - "parameters": { |
53 |
| - "filePath": "src/MyComponent.res", |
54 |
| - "line": 10, |
55 |
| - "col": 5 |
56 |
| - } |
57 |
| -} |
58 |
| -``` |
59 |
| - |
60 |
| -### Find definition of a symbol |
61 |
| - |
62 |
| -```json |
63 |
| -{ |
64 |
| - "tool": "find_definition", |
65 |
| - "parameters": { |
66 |
| - "filePath": "src/MyComponent.res", |
67 |
| - "line": 15, |
68 |
| - "col": 12 |
69 |
| - } |
70 |
| -} |
71 |
| -``` |
72 |
| - |
73 |
| -### Format a file |
74 |
| - |
75 |
| -```json |
76 |
| -{ |
77 |
| - "tool": "format_file", |
78 |
| - "parameters": { |
79 |
| - "filePath": "src/MyComponent.res" |
80 |
| - } |
81 |
| -} |
82 |
| -``` |
83 |
| - |
84 |
| -### Get document symbols |
85 |
| - |
86 |
| -```json |
87 |
| -{ |
88 |
| - "tool": "document_symbols", |
89 |
| - "parameters": { |
90 |
| - "filePath": "src/MyComponent.res" |
91 |
| - } |
92 |
| -} |
93 |
| -``` |
94 |
| - |
95 |
| -## Development |
96 |
| - |
97 |
| -- `npm run dev` - Watch mode for TypeScript compilation |
98 |
| -- `npm run build` - Build the server |
99 |
| -- `npm start` - Run the built server |
100 |
| - |
101 |
| -## Architecture |
102 |
| - |
103 |
| -This MCP server acts as a bridge between MCP clients and the ReScript compiler's analysis engine. It spawns the `rescript-editor-analysis.exe` process to perform the actual language analysis and returns the results through the MCP protocol. |
104 |
| - |
105 |
| -All tools use 0-indexed line and column numbers, following the Language Server Protocol (LSP) specification. |
| 3 | +A Model Context Protocol (MCP) server that provides comprehensive ReScript language support. |
0 commit comments