@macroforge/mcp-server 0.1.40 → 0.1.49
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 +22 -0
- package/docs/BOOK.md +165 -0
- package/docs/api/api-overview.md +65 -46
- package/docs/api/expand-sync.md +88 -53
- package/docs/api/native-plugin.md +121 -71
- package/docs/api/position-mapper.md +114 -54
- package/docs/api/transform-sync.md +85 -59
- package/docs/builtin-macros/clone.md +0 -20
- package/docs/builtin-macros/debug.md +0 -23
- package/docs/builtin-macros/default.md +1 -40
- package/docs/builtin-macros/deserialize/example.md +8 -1416
- package/docs/builtin-macros/deserialize.md +8 -1416
- package/docs/builtin-macros/hash.md +0 -42
- package/docs/builtin-macros/macros-overview/detailed-documentation.md +13 -0
- package/docs/builtin-macros/macros-overview/enum-support.md +30 -0
- package/docs/builtin-macros/macros-overview/interface-support.md +28 -0
- package/docs/builtin-macros/macros-overview/overview.md +36 -0
- package/docs/builtin-macros/macros-overview/type-alias-support.md +62 -0
- package/docs/builtin-macros/macros-overview.md +171 -130
- package/docs/builtin-macros/ord.md +0 -25
- package/docs/builtin-macros/partial-eq.md +0 -84
- package/docs/builtin-macros/partial-ord.md +11 -43
- package/docs/builtin-macros/serialize.md +2 -62
- package/docs/concepts/architecture.md +125 -48
- package/docs/concepts/derive-system/built-in-vs-custom-macros.md +13 -0
- package/docs/concepts/derive-system/overview.md +200 -0
- package/docs/concepts/derive-system.md +171 -97
- package/docs/concepts/how-macros-work.md +89 -37
- package/docs/custom-macros/custom-overview.md +79 -57
- package/docs/custom-macros/rust-setup.md +138 -99
- package/docs/custom-macros/ts-macro-derive/accessing-field-data.md +40 -31
- package/docs/custom-macros/ts-macro-derive/adding-imports.md +14 -11
- package/docs/custom-macros/ts-macro-derive/attribute-options.md +20 -25
- package/docs/custom-macros/ts-macro-derive/complete-example.md +40 -38
- package/docs/custom-macros/ts-macro-derive/deriveinput-structure.md +49 -47
- package/docs/custom-macros/ts-macro-derive/function-signature.md +12 -0
- package/docs/custom-macros/ts-macro-derive/overview.md +9 -7
- package/docs/custom-macros/ts-macro-derive/parsing-input.md +20 -18
- package/docs/custom-macros/ts-macro-derive/returning-errors.md +15 -13
- package/docs/custom-macros/ts-macro-derive.md +322 -228
- package/docs/custom-macros/ts-quote/backtick-template-literals.md +19 -7
- package/docs/custom-macros/ts-quote/comments-and.md +56 -22
- package/docs/custom-macros/ts-quote/complete-example-json-derive-macro.md +89 -98
- package/docs/custom-macros/ts-quote/conditionals-ifif.md +35 -29
- package/docs/custom-macros/ts-quote/identifier-concatenation-content.md +30 -22
- package/docs/custom-macros/ts-quote/iteration-for.md +48 -40
- package/docs/custom-macros/ts-quote/local-constants-let.md +23 -21
- package/docs/custom-macros/ts-quote/match-expressions-match.md +46 -38
- package/docs/custom-macros/ts-quote/overview.md +5 -10
- package/docs/custom-macros/ts-quote/pattern-matching-iflet.md +39 -0
- package/docs/custom-macros/ts-quote/quick-reference.md +50 -129
- package/docs/custom-macros/ts-quote/side-effects-do.md +13 -78
- package/docs/custom-macros/ts-quote/string-interpolation-textexpr.md +36 -0
- package/docs/custom-macros/ts-quote/tsstream-injection-typescript.md +43 -35
- package/docs/custom-macros/ts-quote/while-loops-while.md +31 -23
- package/docs/custom-macros/ts-quote.md +799 -519
- package/docs/getting-started/first-macro.md +61 -32
- package/docs/getting-started/installation.md +109 -66
- package/docs/integration/cli.md +212 -103
- package/docs/integration/configuration.md +114 -71
- package/docs/integration/integration-overview.md +54 -17
- package/docs/integration/mcp-server.md +83 -42
- package/docs/integration/svelte-preprocessor.md +183 -126
- package/docs/integration/typescript-plugin.md +101 -54
- package/docs/integration/vite-plugin.md +116 -76
- package/docs/language-servers/ls-overview.md +37 -21
- package/docs/language-servers/svelte.md +69 -39
- package/docs/language-servers/zed.md +81 -45
- package/docs/roadmap/roadmap.md +75 -53
- package/docs/sections.json +333 -44
- package/package.json +27 -28
|
@@ -1,73 +1,116 @@
|
|
|
1
1
|
# Configuration
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
2
|
+
|
|
3
|
+
Macroforge can be configured with a `macroforge.json` file in your project root.
|
|
4
|
+
|
|
5
|
+
## Configuration File
|
|
6
|
+
|
|
7
|
+
Create a `macroforge.json` file:
|
|
8
|
+
|
|
9
|
+
macroforge.json
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{
|
|
13
|
+
"allowNativeMacros": true,
|
|
14
|
+
"macroPackages": [],
|
|
15
|
+
"keepDecorators": false,
|
|
16
|
+
"limits": {
|
|
17
|
+
"maxExecutionTimeMs": 5000,
|
|
18
|
+
"maxMemoryBytes": 104857600,
|
|
19
|
+
"maxOutputSize": 10485760,
|
|
20
|
+
"maxDiagnostics": 100
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Options Reference
|
|
26
|
+
|
|
27
|
+
### allowNativeMacros
|
|
28
|
+
|
|
29
|
+
| Type | `boolean` |
|
|
30
|
+
| Default | `true` |
|
|
31
|
+
|
|
32
|
+
Enable or disable native (Rust) macro packages. Set to `false` to only allow built-in macros.
|
|
33
|
+
|
|
34
|
+
### macroPackages
|
|
35
|
+
|
|
36
|
+
| Type | `string[]` |
|
|
37
|
+
| Default | `[]` |
|
|
38
|
+
|
|
39
|
+
List of npm packages that provide macros. Macroforge will look for macros in these packages.
|
|
40
|
+
|
|
41
|
+
JSON
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
{
|
|
45
|
+
"macroPackages": [
|
|
46
|
+
"@my-org/custom-macros",
|
|
47
|
+
"community-macros"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### keepDecorators
|
|
53
|
+
|
|
54
|
+
| Type | `boolean` |
|
|
55
|
+
| Default | `false` |
|
|
56
|
+
|
|
57
|
+
Keep `@derive` decorators in the output. Useful for debugging.
|
|
58
|
+
|
|
59
|
+
### limits
|
|
60
|
+
|
|
61
|
+
Configure resource limits for macro expansion:
|
|
62
|
+
|
|
63
|
+
JSON
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
{
|
|
67
|
+
"limits": {
|
|
68
|
+
// Maximum time for a single macro expansion (ms)
|
|
69
|
+
"maxExecutionTimeMs": 5000,
|
|
70
|
+
|
|
71
|
+
// Maximum memory usage (bytes)
|
|
72
|
+
"maxMemoryBytes": 104857600, // 100MB
|
|
73
|
+
|
|
74
|
+
// Maximum size of generated code (bytes)
|
|
75
|
+
"maxOutputSize": 10485760, // 10MB
|
|
76
|
+
|
|
77
|
+
// Maximum number of diagnostics per file
|
|
78
|
+
"maxDiagnostics": 100
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Macro Runtime Overrides
|
|
84
|
+
|
|
85
|
+
Override settings for specific macros:
|
|
86
|
+
|
|
87
|
+
JSON
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
{
|
|
91
|
+
"macroRuntimeOverrides": {
|
|
92
|
+
"@my-org/macros": {
|
|
93
|
+
"maxExecutionTimeMs": 10000
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Warning
|
|
100
|
+
|
|
101
|
+
Be careful when increasing limits, as this could allow malicious macros to consume excessive resources.
|
|
102
|
+
|
|
103
|
+
## Environment Variables
|
|
104
|
+
|
|
105
|
+
Some settings can be overridden with environment variables:
|
|
106
|
+
|
|
107
|
+
| Variable | Description |
|
|
108
|
+
| --------------------- | -------------------- |
|
|
109
|
+
| `MACROFORGE_DEBUG` | Enable debug logging |
|
|
70
110
|
| `MACROFORGE_LOG_FILE` | Write logs to a file |
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
111
|
+
|
|
112
|
+
Bash
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
MACROFORGE_DEBUG=1 npm run dev
|
|
116
|
+
```
|
|
@@ -1,19 +1,56 @@
|
|
|
1
1
|
# Integration
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
Macroforge integrates with your development workflow through IDE plugins and build tool integration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
| Integration | Purpose | Package |
|
|
8
|
+
| ----------------- | --------------------------------- | ------------------------------- |
|
|
6
9
|
| TypeScript Plugin | IDE support (errors, completions) | `@macroforge/typescript-plugin` |
|
|
7
|
-
| Vite Plugin
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
| Vite Plugin | Build-time macro expansion | `@macroforge/vite-plugin` |
|
|
11
|
+
|
|
12
|
+
## Recommended Setup
|
|
13
|
+
|
|
14
|
+
For the best development experience, use both integrations:
|
|
15
|
+
|
|
16
|
+
1. **TypeScript Plugin**: Provides real-time feedback in your IDE
|
|
17
|
+
2. **Vite Plugin**: Expands macros during development and production builds
|
|
18
|
+
|
|
19
|
+
Bash
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
# Install both plugins
|
|
23
|
+
npm install -D @macroforge/typescript-plugin @macroforge/vite-plugin
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## How They Work Together
|
|
27
|
+
|
|
28
|
+
Your Code
|
|
29
|
+
|
|
30
|
+
TypeScript with @derive decorators
|
|
31
|
+
|
|
32
|
+
TypeScript Plugin
|
|
33
|
+
|
|
34
|
+
Language service integration
|
|
35
|
+
|
|
36
|
+
IDE Feedback
|
|
37
|
+
|
|
38
|
+
Errors & completions
|
|
39
|
+
|
|
40
|
+
Vite Plugin
|
|
41
|
+
|
|
42
|
+
Build-time transformation
|
|
43
|
+
|
|
44
|
+
Dev Server
|
|
45
|
+
|
|
46
|
+
Hot reload
|
|
47
|
+
|
|
48
|
+
Production Build
|
|
49
|
+
|
|
50
|
+
Optimized output
|
|
51
|
+
|
|
52
|
+
## Detailed Guides
|
|
53
|
+
|
|
54
|
+
* [TypeScript Plugin setup](../docs/integration/typescript-plugin)
|
|
55
|
+
* [Vite Plugin configuration](../docs/integration/vite-plugin)
|
|
56
|
+
* [Configuration options](../docs/integration/configuration)
|
|
@@ -1,45 +1,86 @@
|
|
|
1
1
|
# MCP Server
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
|
|
3
|
+
The MCP (Model Context Protocol) server enables AI assistants to understand and work with Macroforge macros, providing documentation lookup, code validation, and macro expansion.
|
|
4
|
+
|
|
5
|
+
The local (stdio) version of the MCP server is available via the [`@macroforge/mcp-server`](https://www.npmjs.com/package/@macroforge/mcp-server) npm package. You can either install it globally and then reference it in your configuration or run it with `npx`:
|
|
6
|
+
|
|
7
|
+
Bash
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npx -y @macroforge/mcp-server
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Here's how to set it up in some common MCP clients:
|
|
14
|
+
|
|
15
|
+
## Claude Code
|
|
16
|
+
|
|
17
|
+
To include the local MCP version in Claude Code, simply run the following command:
|
|
18
|
+
|
|
19
|
+
Bash
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
claude mcp add -t stdio -s [scope] macroforge -- npx -y @macroforge/mcp-server
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The `[scope]` must be `user`, `project` or `local`.
|
|
26
|
+
|
|
27
|
+
## Claude Desktop
|
|
28
|
+
|
|
29
|
+
In the Settings > Developer section, click on Edit Config. It will open the folder with a `claude_desktop_config.json` file in it. Edit the file to include the following configuration:
|
|
30
|
+
|
|
31
|
+
claude\_desktop\_config.json
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
{
|
|
35
|
+
"mcpServers": {
|
|
36
|
+
"macroforge": {
|
|
37
|
+
"command": "npx",
|
|
38
|
+
"args": ["-y", "@macroforge/mcp-server"]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Codex CLI
|
|
45
|
+
|
|
46
|
+
Add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to [the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more advanced setups):
|
|
47
|
+
|
|
48
|
+
config.toml
|
|
49
|
+
|
|
50
|
+
```
|
|
26
51
|
[mcp_servers.macroforge]
|
|
27
|
-
command
|
|
28
|
-
args
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
command = "npx"
|
|
53
|
+
args = ["-y", "@macroforge/mcp-server"]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Gemini CLI
|
|
57
|
+
|
|
58
|
+
To include the local MCP version in Gemini CLI, simply run the following command:
|
|
59
|
+
|
|
60
|
+
Bash
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
gemini mcp add -t stdio -s [scope] macroforge npx -y @macroforge/mcp-server
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The `[scope]` must be `user`, `project` or `local`.
|
|
67
|
+
|
|
68
|
+
## Other Clients
|
|
69
|
+
|
|
70
|
+
If we didn't include the MCP client you are using, refer to their documentation for `stdio` servers and use `npx` as the command and `-y @macroforge/mcp-server` as the arguments.
|
|
71
|
+
|
|
72
|
+
## Available Tools
|
|
73
|
+
|
|
74
|
+
The MCP server provides five tools for AI assistants:
|
|
75
|
+
|
|
76
|
+
| Tool | Description |
|
|
77
|
+
| ---------------------- | ---------------------------------------------------------------- |
|
|
78
|
+
| `list-sections` | Lists all available Macroforge documentation sections |
|
|
79
|
+
| `get-documentation` | Retrieves full documentation for one or more sections |
|
|
42
80
|
| `macroforge-autofixer` | Validates code with `@derive` decorators and returns diagnostics |
|
|
43
|
-
| `expand-code`
|
|
44
|
-
| `get-macro-info`
|
|
45
|
-
|
|
81
|
+
| `expand-code` | Expands macros and returns the transformed TypeScript code |
|
|
82
|
+
| `get-macro-info` | Retrieves documentation for macros and field decorators |
|
|
83
|
+
|
|
84
|
+
Note
|
|
85
|
+
|
|
86
|
+
For code validation and expansion features (`macroforge-autofixer`, `expand-code`, `get-macro-info`), the MCP server requires `macroforge` as a peer dependency. Install it in your project with `npm install macroforge`.
|