@boperators/mcp-server 0.1.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 +162 -0
- package/dist/index.js +262533 -0
- package/license.txt +8 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# @boperators/mcp-server
|
|
2
|
+
|
|
3
|
+
An [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that gives AI assistants access to operator overload information in a [boperators](https://www.npmjs.com/package/boperators) project. Useful when asking an AI to read, write, or debug operator overloads — the server lets it inspect what overloads are defined, preview transformations, generate boilerplate, and validate definitions without having to read every source file manually.
|
|
4
|
+
|
|
5
|
+
The server communicates over stdio and is launched on demand by the AI client.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -D @boperators/mcp-server
|
|
11
|
+
# or
|
|
12
|
+
bun add -D @boperators/mcp-server
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`boperators` and a compatible TypeScript must also be present as peer dependencies.
|
|
16
|
+
|
|
17
|
+
## Tools
|
|
18
|
+
|
|
19
|
+
| Tool | Description | Requires `tsconfig` |
|
|
20
|
+
|------|-------------|:-------------------:|
|
|
21
|
+
| [`list_overloads`](#list_overloads) | List all registered overloads in the project, with optional filtering by class or operator | ✓ |
|
|
22
|
+
| [`transform_preview`](#transform_preview) | Preview the transformed output for a file or a line range within it | ✓ |
|
|
23
|
+
| [`scaffold_overloads`](#scaffold_overloads) | Generate `as const` boilerplate for a set of operators on a named class | — |
|
|
24
|
+
| [`validate_overloads`](#validate_overloads) | Validate overload definitions in a single file and return structured diagnostics | ✓ |
|
|
25
|
+
| [`explain_expression`](#explain_expression) | Reverse-engineer a transformed call expression back to its original operator and overload metadata | optional |
|
|
26
|
+
|
|
27
|
+
### `list_overloads`
|
|
28
|
+
|
|
29
|
+
Returns every overload registered in the project — class name, operator, parameter types, return convention, and source file. Accepts optional `className` and `operator` filters to narrow results.
|
|
30
|
+
|
|
31
|
+
**Inputs**
|
|
32
|
+
|
|
33
|
+
| Parameter | Type | Required | Description |
|
|
34
|
+
|-----------|------|:--------:|-------------|
|
|
35
|
+
| `tsconfig` | `string` | ✓ | Absolute path to `tsconfig.json` |
|
|
36
|
+
| `className` | `string` | — | Filter to a specific class, e.g. `"Vector3"` |
|
|
37
|
+
| `operator` | `string` | — | Filter to a specific operator, e.g. `"+"` |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### `transform_preview`
|
|
42
|
+
|
|
43
|
+
Transforms a file and returns the original and transformed text side by side, along with a count of how many operator expressions were rewritten. When `startLine`/`endLine` are given, only that slice is returned — useful for keeping token usage low on large files.
|
|
44
|
+
|
|
45
|
+
**Inputs**
|
|
46
|
+
|
|
47
|
+
| Parameter | Type | Required | Description |
|
|
48
|
+
|-----------|------|:--------:|-------------|
|
|
49
|
+
| `tsconfig` | `string` | ✓ | Absolute path to `tsconfig.json` |
|
|
50
|
+
| `filePath` | `string` | ✓ | Absolute path to the `.ts` file to transform |
|
|
51
|
+
| `startLine` | `number` | — | First line to include (1-based, inclusive) |
|
|
52
|
+
| `endLine` | `number` | — | Last line to include (1-based, inclusive) |
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### `scaffold_overloads`
|
|
57
|
+
|
|
58
|
+
Generates ready-to-paste TypeScript property declarations for a list of operators on a given class. Automatically uses the correct form for each operator:
|
|
59
|
+
|
|
60
|
+
- **Static binary** (`+`, `-`, `*`, …) — `static readonly "+" = [(a: T, b: T): T => { … }] as const`
|
|
61
|
+
- **Comparison** (`>`, `==`, …) — static, returns `boolean`
|
|
62
|
+
- **Instance compound** (`+=`, `-=`, …) — instance, `function(this: T, rhs: T): void`
|
|
63
|
+
- **Prefix unary** (`!`, `~`) — static, one parameter
|
|
64
|
+
- **Postfix unary** (`++`, `--`) — instance, no parameters, returns `void`
|
|
65
|
+
|
|
66
|
+
Does not require a `tsconfig` — it is purely generative.
|
|
67
|
+
|
|
68
|
+
**Inputs**
|
|
69
|
+
|
|
70
|
+
| Parameter | Type | Required | Description |
|
|
71
|
+
|-----------|------|:--------:|-------------|
|
|
72
|
+
| `className` | `string` | ✓ | The class to generate overloads for |
|
|
73
|
+
| `operators` | `string[]` | ✓ | Operator strings, e.g. `["+", "-", "*", "+="]` |
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### `validate_overloads`
|
|
78
|
+
|
|
79
|
+
Runs the boperators scanning pipeline against a single file in isolation and returns structured diagnostics without modifying any state. Reports:
|
|
80
|
+
|
|
81
|
+
- **Errors** — wrong arity, missing `as const`, return type violations
|
|
82
|
+
- **Warnings** — duplicate/conflicting overload registrations
|
|
83
|
+
- The count of successfully parsed overloads
|
|
84
|
+
|
|
85
|
+
**Inputs**
|
|
86
|
+
|
|
87
|
+
| Parameter | Type | Required | Description |
|
|
88
|
+
|-----------|------|:--------:|-------------|
|
|
89
|
+
| `tsconfig` | `string` | ✓ | Absolute path to `tsconfig.json` |
|
|
90
|
+
| `filePath` | `string` | ✓ | Absolute path to the `.ts` file to validate |
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### `explain_expression`
|
|
95
|
+
|
|
96
|
+
Given a transformed boperators expression (e.g. `Vector3["+"][0](a, b)` or `v["+="][0].call(v, rhs)`), decodes it back to the original operator, identifies whether it is static/instance and binary/unary, and optionally enriches the result with metadata from the project's overload store.
|
|
97
|
+
|
|
98
|
+
**Inputs**
|
|
99
|
+
|
|
100
|
+
| Parameter | Type | Required | Description |
|
|
101
|
+
|-----------|------|:--------:|-------------|
|
|
102
|
+
| `expression` | `string` | ✓ | The transformed call expression to explain |
|
|
103
|
+
| `tsconfig` | `string` | — | Absolute path to `tsconfig.json`; enables richer metadata |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Setup
|
|
108
|
+
|
|
109
|
+
### Claude
|
|
110
|
+
|
|
111
|
+
For Claude Desktop:
|
|
112
|
+
|
|
113
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
114
|
+
|
|
115
|
+
For Claude Code:
|
|
116
|
+
|
|
117
|
+
Add to `.mcp.json` at the root of your project (checked in, shared with the team) or via `~/.claude/settings.json` for a user-level install:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"mcpServers": {
|
|
122
|
+
"boperators": {
|
|
123
|
+
"command": "npx",
|
|
124
|
+
"args": ["@boperators/mcp-server@latest"]
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### GitHub Copilot (VS Code)
|
|
131
|
+
|
|
132
|
+
Add to `.vscode/mcp.json` in your workspace,
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"servers": {
|
|
137
|
+
"boperators": {
|
|
138
|
+
"command": "npx",
|
|
139
|
+
"args": ["@boperators/mcp-server@latest"]
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Or add it directly to your VS Code `settings.json`:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"mcp.servers": {
|
|
150
|
+
"boperators": {
|
|
151
|
+
"command": "npx",
|
|
152
|
+
"args": ["@boperators/mcp-server@latest"]
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Enable the server in the Copilot Chat panel by clicking **MCP Servers → boperators**.
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
MIT
|