equilibria-mcp-server 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/CHANGELOG.md +142 -0
- package/LICENSE +21 -0
- package/README.md +240 -0
- package/dist/builders/YAMLBuilder.d.ts +77 -0
- package/dist/builders/YAMLBuilder.d.ts.map +1 -0
- package/dist/builders/YAMLBuilder.js +251 -0
- package/dist/builders/YAMLBuilder.js.map +1 -0
- package/dist/economics/constants.d.ts +39 -0
- package/dist/economics/constants.d.ts.map +1 -0
- package/dist/economics/constants.js +46 -0
- package/dist/economics/constants.js.map +1 -0
- package/dist/economics/formulas.d.ts +19 -0
- package/dist/economics/formulas.d.ts.map +1 -0
- package/dist/economics/formulas.js +260 -0
- package/dist/economics/formulas.js.map +1 -0
- package/dist/economics/index.d.ts +9 -0
- package/dist/economics/index.d.ts.map +1 -0
- package/dist/economics/index.js +9 -0
- package/dist/economics/index.js.map +1 -0
- package/dist/economics/validators.d.ts +18 -0
- package/dist/economics/validators.d.ts.map +1 -0
- package/dist/economics/validators.js +111 -0
- package/dist/economics/validators.js.map +1 -0
- package/dist/errors/index.d.ts +172 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +313 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/formatters/index.d.ts +8 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +8 -0
- package/dist/formatters/index.js.map +1 -0
- package/dist/formatters/redux.d.ts +15 -0
- package/dist/formatters/redux.d.ts.map +1 -0
- package/dist/formatters/redux.js +35 -0
- package/dist/formatters/redux.js.map +1 -0
- package/dist/formatters/yaml.d.ts +18 -0
- package/dist/formatters/yaml.d.ts.map +1 -0
- package/dist/formatters/yaml.js +40 -0
- package/dist/formatters/yaml.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +14 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +86 -0
- package/dist/server.js.map +1 -0
- package/dist/templates/advancedMicro.d.ts +8 -0
- package/dist/templates/advancedMicro.d.ts.map +1 -0
- package/dist/templates/advancedMicro.js +834 -0
- package/dist/templates/advancedMicro.js.map +1 -0
- package/dist/templates/consumer.d.ts +12 -0
- package/dist/templates/consumer.d.ts.map +1 -0
- package/dist/templates/consumer.js +1978 -0
- package/dist/templates/consumer.js.map +1 -0
- package/dist/templates/elasticity.d.ts +8 -0
- package/dist/templates/elasticity.d.ts.map +1 -0
- package/dist/templates/elasticity.js +500 -0
- package/dist/templates/elasticity.js.map +1 -0
- package/dist/templates/externalities.d.ts +11 -0
- package/dist/templates/externalities.d.ts.map +1 -0
- package/dist/templates/externalities.js +997 -0
- package/dist/templates/externalities.js.map +1 -0
- package/dist/templates/financeBehavioral.d.ts +8 -0
- package/dist/templates/financeBehavioral.d.ts.map +1 -0
- package/dist/templates/financeBehavioral.js +860 -0
- package/dist/templates/financeBehavioral.js.map +1 -0
- package/dist/templates/growth.d.ts +8 -0
- package/dist/templates/growth.d.ts.map +1 -0
- package/dist/templates/growth.js +740 -0
- package/dist/templates/growth.js.map +1 -0
- package/dist/templates/index.d.ts +31 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +91 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/inequality.d.ts +8 -0
- package/dist/templates/inequality.d.ts.map +1 -0
- package/dist/templates/inequality.js +562 -0
- package/dist/templates/inequality.js.map +1 -0
- package/dist/templates/intertemporalMacro.d.ts +8 -0
- package/dist/templates/intertemporalMacro.d.ts.map +1 -0
- package/dist/templates/intertemporalMacro.js +550 -0
- package/dist/templates/intertemporalMacro.js.map +1 -0
- package/dist/templates/isLM.d.ts +8 -0
- package/dist/templates/isLM.d.ts.map +1 -0
- package/dist/templates/isLM.js +747 -0
- package/dist/templates/isLM.js.map +1 -0
- package/dist/templates/macro.d.ts +8 -0
- package/dist/templates/macro.d.ts.map +1 -0
- package/dist/templates/macro.js +600 -0
- package/dist/templates/macro.js.map +1 -0
- package/dist/templates/marketStructures.d.ts +11 -0
- package/dist/templates/marketStructures.d.ts.map +1 -0
- package/dist/templates/marketStructures.js +1135 -0
- package/dist/templates/marketStructures.js.map +1 -0
- package/dist/templates/newKeynesian.d.ts +8 -0
- package/dist/templates/newKeynesian.d.ts.map +1 -0
- package/dist/templates/newKeynesian.js +633 -0
- package/dist/templates/newKeynesian.js.map +1 -0
- package/dist/templates/oligopoly.d.ts +11 -0
- package/dist/templates/oligopoly.d.ts.map +1 -0
- package/dist/templates/oligopoly.js +1113 -0
- package/dist/templates/oligopoly.js.map +1 -0
- package/dist/templates/ppf.d.ts +8 -0
- package/dist/templates/ppf.d.ts.map +1 -0
- package/dist/templates/ppf.js +439 -0
- package/dist/templates/ppf.js.map +1 -0
- package/dist/templates/producer.d.ts +11 -0
- package/dist/templates/producer.d.ts.map +1 -0
- package/dist/templates/producer.js +979 -0
- package/dist/templates/producer.js.map +1 -0
- package/dist/templates/production.d.ts +8 -0
- package/dist/templates/production.d.ts.map +1 -0
- package/dist/templates/production.js +574 -0
- package/dist/templates/production.js.map +1 -0
- package/dist/templates/supplyDemand.d.ts +8 -0
- package/dist/templates/supplyDemand.d.ts.map +1 -0
- package/dist/templates/supplyDemand.js +1282 -0
- package/dist/templates/supplyDemand.js.map +1 -0
- package/dist/templates/tradeGrowth.d.ts +8 -0
- package/dist/templates/tradeGrowth.d.ts.map +1 -0
- package/dist/templates/tradeGrowth.js +637 -0
- package/dist/templates/tradeGrowth.js.map +1 -0
- package/dist/tools/index.d.ts +25 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +54 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/models.d.ts +8 -0
- package/dist/tools/models.d.ts.map +1 -0
- package/dist/tools/models.js +828 -0
- package/dist/tools/models.js.map +1 -0
- package/dist/tools/output.d.ts +8 -0
- package/dist/tools/output.d.ts.map +1 -0
- package/dist/tools/output.js +236 -0
- package/dist/tools/output.js.map +1 -0
- package/dist/tools/templates.d.ts +8 -0
- package/dist/tools/templates.d.ts.map +1 -0
- package/dist/tools/templates.js +247 -0
- package/dist/tools/templates.js.map +1 -0
- package/dist/tools/validation.d.ts +8 -0
- package/dist/tools/validation.d.ts.map +1 -0
- package/dist/tools/validation.js +181 -0
- package/dist/tools/validation.js.map +1 -0
- package/dist/types/index.d.ts +187 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/cache.d.ts +99 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +192 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +128 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +251 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/validation/index.d.ts +42 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +282 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +73 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the Equilibria MCP Server will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-01-02
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
#### MCP Server Infrastructure
|
|
13
|
+
- Model Context Protocol server with stdio transport
|
|
14
|
+
- Tool registration framework with 17 MCP tools
|
|
15
|
+
- Session state management for multi-step operations
|
|
16
|
+
- Shared context for incremental document building
|
|
17
|
+
|
|
18
|
+
#### Economic Model Templates (88 total)
|
|
19
|
+
- **Supply & Demand** (8 templates): basic, surplus, tax, price ceiling, price floor, subsidy, quota, shift
|
|
20
|
+
- **PPF** (4 templates): linear, concave, growth, comparative advantage
|
|
21
|
+
- **Elasticity** (4 templates): demand, total revenue test, comparison, cross elasticity
|
|
22
|
+
- **Production & Cost** (4 templates): short-run production, cost curves, LRAC, profit maximization
|
|
23
|
+
- **Basic Macro** (5 templates): AD-AS basic, AD-AS demand shock, money market, business cycle, Phillips curve
|
|
24
|
+
- **Inequality** (4 templates): Lorenz curve, Laffer curve, progressive tax, income quintiles
|
|
25
|
+
- **Consumer Theory** (11 templates): budget constraints (5 variants), indifference curves (3 types), optimal choice, ICC, PCC
|
|
26
|
+
- **Producer Theory** (5 templates): isoquants, isocost, cost minimization, expansion path, returns to scale
|
|
27
|
+
- **Market Structures** (6 templates): perfect competition (2), monopoly (2), price discrimination (2)
|
|
28
|
+
- **Oligopoly** (5 templates): Cournot, Bertrand, Stackelberg, kinked demand, monopolistic competition
|
|
29
|
+
- **Externalities** (5 templates): negative, positive, Pigouvian tax, Coase theorem, public goods
|
|
30
|
+
- **IS-LM** (5 templates): basic, fiscal policy, monetary policy, policy mix, Mundell-Fleming
|
|
31
|
+
- **Growth** (6 templates): expectations Phillips, supply shock, Solow basic, golden rule, AK model
|
|
32
|
+
- **Intertemporal Macro** (3 templates): Ramsey-Cass-Koopmans, OLG, RBC
|
|
33
|
+
- **New Keynesian** (4 templates): NK IS, NK Phillips, Taylor rule, three-equation
|
|
34
|
+
- **International Trade** (4 templates): Romer endogenous growth, Heckscher-Ohlin, offer curves, terms of trade
|
|
35
|
+
- **Advanced Micro** (4 templates): Edgeworth box, Slutsky equation, principal-agent, mechanism design
|
|
36
|
+
- **Finance & Behavioral** (5 templates): efficient frontier, CAPM, Black-Scholes, prospect theory, hyperbolic discounting
|
|
37
|
+
|
|
38
|
+
#### MCP Tools
|
|
39
|
+
- **Template Tools**: `generate_economic_model`, `list_available_models`, `get_model_schema`
|
|
40
|
+
- **Model Building Tools**: `create_chart`, `add_curve`, `add_point`, `add_area`, `add_parameter`, `add_annotation`, `add_vertical_line`, `add_horizontal_line`, `export_document`
|
|
41
|
+
- **Validation Tools**: `validate_expression`, `validate_yaml`, `check_dependencies`
|
|
42
|
+
- **Output Tools**: `convert_yaml_to_redux`, `get_economic_formulas`
|
|
43
|
+
|
|
44
|
+
#### YAML Document Builder
|
|
45
|
+
- Fluent API for constructing Equilibria documents
|
|
46
|
+
- Support for parameters, charts, elements, and annotations
|
|
47
|
+
- Type-safe builder with chainable methods
|
|
48
|
+
|
|
49
|
+
#### Validation Layer
|
|
50
|
+
- Expression syntax validation using mathjs
|
|
51
|
+
- Zod schema integration with equilibria-engine
|
|
52
|
+
- Circular dependency detection with topological sort
|
|
53
|
+
- Cross-reference validation
|
|
54
|
+
- Levenshtein-based "did you mean" suggestions
|
|
55
|
+
|
|
56
|
+
#### Economic Knowledge Base
|
|
57
|
+
- 40+ economic formulas (equilibrium, surplus, elasticity, production, utility, cost, macro)
|
|
58
|
+
- Economic constraint validators
|
|
59
|
+
- Default constants and sensible ranges
|
|
60
|
+
|
|
61
|
+
#### Output Formatters
|
|
62
|
+
- YAML string formatter
|
|
63
|
+
- Redux state object formatter
|
|
64
|
+
- API call sequence formatter (planned)
|
|
65
|
+
|
|
66
|
+
#### Error Handling (Phase 8)
|
|
67
|
+
- Enhanced error messages with recovery suggestions
|
|
68
|
+
- Error codes and categories for systematic handling
|
|
69
|
+
- Detailed examples in error messages
|
|
70
|
+
- Documentation links in errors
|
|
71
|
+
|
|
72
|
+
#### Performance Optimizations (Phase 8)
|
|
73
|
+
- Validation caching with LRU eviction
|
|
74
|
+
- Expression validation cache (no TTL)
|
|
75
|
+
- Document validation cache (1 minute TTL)
|
|
76
|
+
- Cache statistics and management utilities
|
|
77
|
+
|
|
78
|
+
#### Logging & Debugging (Phase 8)
|
|
79
|
+
- Structured logging utility (stderr output)
|
|
80
|
+
- Log levels: debug, info, warn, error
|
|
81
|
+
- Performance measurement helpers
|
|
82
|
+
- Tool invocation logging
|
|
83
|
+
|
|
84
|
+
#### Documentation
|
|
85
|
+
- Comprehensive tool reference (TOOL_REFERENCE.md)
|
|
86
|
+
- Economic models guide (ECONOMIC_MODELS.md)
|
|
87
|
+
- API documentation (API.md)
|
|
88
|
+
- Usage examples and Claude Desktop configuration
|
|
89
|
+
|
|
90
|
+
### Testing
|
|
91
|
+
- 291 tests across 7 test suites
|
|
92
|
+
- Template generation tests
|
|
93
|
+
- Tool handler tests
|
|
94
|
+
- Economic validation tests
|
|
95
|
+
- Expression validation tests
|
|
96
|
+
- Builder tests
|
|
97
|
+
- Formatter tests
|
|
98
|
+
|
|
99
|
+
### Dependencies
|
|
100
|
+
- `@modelcontextprotocol/sdk` - MCP protocol implementation
|
|
101
|
+
- `equilibria-engine` - Graph rendering engine (workspace)
|
|
102
|
+
- `mathjs` - Expression parsing and validation
|
|
103
|
+
- `zod` - Schema validation
|
|
104
|
+
- `js-yaml` - YAML handling
|
|
105
|
+
|
|
106
|
+
### Technical Details
|
|
107
|
+
- TypeScript with strict mode
|
|
108
|
+
- ES modules
|
|
109
|
+
- Node.js >= 18.0.0
|
|
110
|
+
- Vitest for testing
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## [0.1.0] - 2025-12-31
|
|
115
|
+
|
|
116
|
+
### Added
|
|
117
|
+
- Initial project structure
|
|
118
|
+
- MCP server scaffold
|
|
119
|
+
- Basic supply and demand templates
|
|
120
|
+
- Foundation for template library
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Future Roadmap
|
|
125
|
+
|
|
126
|
+
### [1.1.0] - Planned
|
|
127
|
+
- Additional economic model templates
|
|
128
|
+
- Template composition (combining multiple models)
|
|
129
|
+
- Interactive tutorial templates
|
|
130
|
+
- Custom template registration API
|
|
131
|
+
|
|
132
|
+
### [1.2.0] - Planned
|
|
133
|
+
- Performance profiling and optimization
|
|
134
|
+
- Streaming for large document generation
|
|
135
|
+
- Batch validation API
|
|
136
|
+
- Template versioning
|
|
137
|
+
|
|
138
|
+
### [2.0.0] - Planned
|
|
139
|
+
- Breaking API improvements based on user feedback
|
|
140
|
+
- Advanced macro models (DSGE extensions)
|
|
141
|
+
- Econometric visualization templates
|
|
142
|
+
- Multi-language support for labels
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kinetonomics
|
|
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,240 @@
|
|
|
1
|
+
# Equilibria MCP Server
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server that enables AI assistants to generate sophisticated economic visualizations using the Equilibria Engine through natural language interactions.
|
|
4
|
+
|
|
5
|
+
**Version**: 1.0.0
|
|
6
|
+
**Status**: Production Ready
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **88 Economic Model Templates** - From high school to postgraduate level
|
|
11
|
+
- **17 MCP Tools** - Complete API for model generation and customization
|
|
12
|
+
- **Multiple Output Formats** - YAML, Redux state, API call sequences
|
|
13
|
+
- **Expression Validation** - Mathematical syntax checking with suggestions
|
|
14
|
+
- **Economic Knowledge Base** - 40+ formulas with validation rules
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### Installation
|
|
19
|
+
|
|
20
|
+
#### Option 1: Install from NPM (Recommended)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g equilibria-mcp-server
|
|
24
|
+
# or
|
|
25
|
+
pnpm add -g equilibria-mcp-server
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### Option 2: Install from Source
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Clone the repository
|
|
32
|
+
git clone https://github.com/DingleDongle93/Equilibria.git
|
|
33
|
+
cd Equilibria/equilibria-monorepo
|
|
34
|
+
|
|
35
|
+
# Install dependencies
|
|
36
|
+
pnpm install
|
|
37
|
+
|
|
38
|
+
# Build the MCP server
|
|
39
|
+
pnpm --filter equilibria-mcp-server build
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Claude Desktop Integration
|
|
43
|
+
|
|
44
|
+
Add to your Claude Desktop configuration:
|
|
45
|
+
|
|
46
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
47
|
+
**Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
48
|
+
**Linux**: `~/.config/claude/claude_desktop_config.json`
|
|
49
|
+
|
|
50
|
+
#### If installed via NPM:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"mcpServers": {
|
|
55
|
+
"equilibria": {
|
|
56
|
+
"command": "equilibria-mcp-server"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### If installed from source:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"equilibria": {
|
|
68
|
+
"command": "node",
|
|
69
|
+
"args": ["/path/to/equilibria-mcp-server/dist/index.js"]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Test the Integration
|
|
76
|
+
|
|
77
|
+
After configuring, restart Claude Desktop and try:
|
|
78
|
+
|
|
79
|
+
> "Generate a supply and demand chart with equilibrium at price 50"
|
|
80
|
+
|
|
81
|
+
## Available Tools
|
|
82
|
+
|
|
83
|
+
### Template Tools (High-Level)
|
|
84
|
+
| Tool | Description |
|
|
85
|
+
|------|-------------|
|
|
86
|
+
| `generate_economic_model` | Generate complete visualization from template |
|
|
87
|
+
| `list_available_models` | List all available templates by category |
|
|
88
|
+
| `get_model_schema` | Get parameter schema for a template |
|
|
89
|
+
|
|
90
|
+
### Model Building Tools (Mid-Level)
|
|
91
|
+
| Tool | Description |
|
|
92
|
+
|------|-------------|
|
|
93
|
+
| `create_chart` | Initialize a new chart |
|
|
94
|
+
| `add_curve` | Add curve/line with equation |
|
|
95
|
+
| `add_point` | Add point (explicit or intersection) |
|
|
96
|
+
| `add_area` | Add shaded region |
|
|
97
|
+
| `add_parameter` | Add interactive parameter |
|
|
98
|
+
| `add_annotation` | Add text label |
|
|
99
|
+
| `add_vertical_line` | Add vertical reference line |
|
|
100
|
+
| `add_horizontal_line` | Add horizontal reference line |
|
|
101
|
+
| `export_document` | Export as YAML |
|
|
102
|
+
|
|
103
|
+
### Validation Tools
|
|
104
|
+
| Tool | Description |
|
|
105
|
+
|------|-------------|
|
|
106
|
+
| `validate_expression` | Check mathematical syntax |
|
|
107
|
+
| `validate_yaml` | Validate document schema |
|
|
108
|
+
| `check_dependencies` | Detect circular dependencies |
|
|
109
|
+
|
|
110
|
+
### Output Tools
|
|
111
|
+
| Tool | Description |
|
|
112
|
+
|------|-------------|
|
|
113
|
+
| `convert_yaml_to_redux` | Convert to Redux state |
|
|
114
|
+
| `get_economic_formulas` | List economic formulas |
|
|
115
|
+
|
|
116
|
+
## Economic Models
|
|
117
|
+
|
|
118
|
+
88 templates across 18 categories:
|
|
119
|
+
|
|
120
|
+
| Category | Models | Level |
|
|
121
|
+
|----------|--------|-------|
|
|
122
|
+
| Supply & Demand | 8 | High School |
|
|
123
|
+
| PPF | 4 | High School |
|
|
124
|
+
| Elasticity | 4 | High School/Undergrad |
|
|
125
|
+
| Production & Cost | 4 | Undergraduate |
|
|
126
|
+
| Basic Macro | 5 | High School/Undergrad |
|
|
127
|
+
| Inequality | 4 | Undergraduate |
|
|
128
|
+
| Consumer Theory | 11 | Undergraduate |
|
|
129
|
+
| Producer Theory | 5 | Undergraduate |
|
|
130
|
+
| Market Structures | 6 | Undergraduate |
|
|
131
|
+
| Oligopoly | 5 | Undergraduate |
|
|
132
|
+
| Externalities | 5 | Undergraduate |
|
|
133
|
+
| IS-LM | 5 | Undergraduate |
|
|
134
|
+
| Growth | 6 | Undergraduate/Postgrad |
|
|
135
|
+
| Intertemporal Macro | 3 | Postgraduate |
|
|
136
|
+
| New Keynesian | 4 | Postgraduate |
|
|
137
|
+
| International Trade | 4 | Undergraduate/Postgrad |
|
|
138
|
+
| Advanced Micro | 4 | Postgraduate |
|
|
139
|
+
| Finance & Behavioral | 5 | Postgraduate |
|
|
140
|
+
|
|
141
|
+
See [Economic Models Guide](./docs/ECONOMIC_MODELS.md) for complete documentation.
|
|
142
|
+
|
|
143
|
+
## Example Usage
|
|
144
|
+
|
|
145
|
+
### Generate from Template
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
User: Generate a monopoly model with marginal cost of 25
|
|
149
|
+
|
|
150
|
+
Claude: [Uses generate_economic_model with model="monopoly_basic" and parameters={marginalCost: 25}]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Build Custom Model
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
User: Create a custom chart showing how a tax affects market equilibrium
|
|
157
|
+
|
|
158
|
+
Claude: [Uses create_chart, add_curve, add_area, add_point, export_document sequentially]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Validate Expression
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
User: Is this expression valid? slope * x^2 + intercept
|
|
165
|
+
|
|
166
|
+
Claude: [Uses validate_expression to check syntax]
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Development
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Development mode with hot reload
|
|
173
|
+
pnpm dev
|
|
174
|
+
|
|
175
|
+
# Run tests
|
|
176
|
+
pnpm test
|
|
177
|
+
|
|
178
|
+
# Type check
|
|
179
|
+
pnpm type-check
|
|
180
|
+
|
|
181
|
+
# Build
|
|
182
|
+
pnpm build
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Test Coverage
|
|
186
|
+
|
|
187
|
+
- 291 tests across 7 test files
|
|
188
|
+
- Template generation tests
|
|
189
|
+
- Tool handler tests
|
|
190
|
+
- Economic validation tests
|
|
191
|
+
- Expression validation tests
|
|
192
|
+
|
|
193
|
+
## Documentation
|
|
194
|
+
|
|
195
|
+
- [Tool Reference](./docs/TOOL_REFERENCE.md) - Complete tool documentation
|
|
196
|
+
- [Economic Models Guide](./docs/ECONOMIC_MODELS.md) - All 88 model templates
|
|
197
|
+
- [API Documentation](./docs/API.md) - Integration and programmatic usage
|
|
198
|
+
- [Implementation Plan](./docs/IMPLEMENTATION_PLAN.md) - Development roadmap
|
|
199
|
+
- [Examples](./examples/) - Usage examples and Claude Desktop config
|
|
200
|
+
|
|
201
|
+
## Architecture
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
equilibria-mcp-server/
|
|
205
|
+
├── src/
|
|
206
|
+
│ ├── index.ts # Entry point
|
|
207
|
+
│ ├── server.ts # MCP server setup
|
|
208
|
+
│ ├── builders/ # YAML document builder
|
|
209
|
+
│ ├── economics/ # Formulas, validators, constants
|
|
210
|
+
│ ├── formatters/ # Output formatters
|
|
211
|
+
│ ├── templates/ # 88 economic model templates
|
|
212
|
+
│ ├── tools/ # MCP tool implementations
|
|
213
|
+
│ ├── types/ # TypeScript types
|
|
214
|
+
│ └── validation/ # Expression & document validation
|
|
215
|
+
├── docs/ # Documentation
|
|
216
|
+
├── examples/ # Usage examples
|
|
217
|
+
└── __tests__/ # Test suites
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Technical Stack
|
|
221
|
+
|
|
222
|
+
- **Language**: TypeScript
|
|
223
|
+
- **MCP SDK**: @modelcontextprotocol/sdk
|
|
224
|
+
- **Engine**: equilibria-engine (monorepo)
|
|
225
|
+
- **Validation**: Zod schemas
|
|
226
|
+
- **Math Parsing**: mathjs
|
|
227
|
+
- **Testing**: Vitest
|
|
228
|
+
|
|
229
|
+
## Requirements
|
|
230
|
+
|
|
231
|
+
- Node.js >= 18.0.0
|
|
232
|
+
- pnpm (recommended) or npm
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
MIT
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
**Questions?** See the [documentation](./docs/) or [examples](./examples/).
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML Document Builder
|
|
3
|
+
*
|
|
4
|
+
* Fluent API for constructing Equilibria YAML documents programmatically.
|
|
5
|
+
*/
|
|
6
|
+
import type { ParameterConfig, ChartConfig, ElementConfig, AnnotationConfig } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Builder class for constructing Equilibria documents
|
|
9
|
+
*/
|
|
10
|
+
export declare class YAMLBuilder {
|
|
11
|
+
private state;
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Set document title
|
|
15
|
+
*/
|
|
16
|
+
setTitle(title: string): this;
|
|
17
|
+
/**
|
|
18
|
+
* Set document description
|
|
19
|
+
*/
|
|
20
|
+
setDescription(description: string): this;
|
|
21
|
+
/**
|
|
22
|
+
* Set spec version
|
|
23
|
+
*/
|
|
24
|
+
setSpecVersion(version: string): this;
|
|
25
|
+
/**
|
|
26
|
+
* Add a global parameter
|
|
27
|
+
*/
|
|
28
|
+
addParameter(name: string, config: ParameterConfig, chartId?: string): this;
|
|
29
|
+
/**
|
|
30
|
+
* Add multiple parameters at once
|
|
31
|
+
*/
|
|
32
|
+
addParameters(params: Record<string, ParameterConfig>, chartId?: string): this;
|
|
33
|
+
/**
|
|
34
|
+
* Add a chart
|
|
35
|
+
*/
|
|
36
|
+
addChart(config: ChartConfig): this;
|
|
37
|
+
/**
|
|
38
|
+
* Get a chart by ID
|
|
39
|
+
*/
|
|
40
|
+
getChart(chartId: string): ChartConfig | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Add an element to a chart
|
|
43
|
+
*/
|
|
44
|
+
addElement(chartId: string, element: ElementConfig): this;
|
|
45
|
+
/**
|
|
46
|
+
* Add an annotation to a chart
|
|
47
|
+
*/
|
|
48
|
+
addAnnotation(chartId: string, annotation: AnnotationConfig): this;
|
|
49
|
+
/**
|
|
50
|
+
* Build the final document object
|
|
51
|
+
*/
|
|
52
|
+
build(): Record<string, unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* Format parameters for output
|
|
55
|
+
*/
|
|
56
|
+
private formatParameters;
|
|
57
|
+
/**
|
|
58
|
+
* Format a chart for output
|
|
59
|
+
*/
|
|
60
|
+
private formatChart;
|
|
61
|
+
/**
|
|
62
|
+
* Reset the builder to initial state
|
|
63
|
+
*/
|
|
64
|
+
reset(): this;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Convenience function to create a supply and demand document
|
|
68
|
+
*/
|
|
69
|
+
export declare function createSupplyDemandDocument(options: {
|
|
70
|
+
title?: string;
|
|
71
|
+
demandIntercept?: number;
|
|
72
|
+
demandSlope?: number;
|
|
73
|
+
supplyIntercept?: number;
|
|
74
|
+
supplySlope?: number;
|
|
75
|
+
showSurplus?: boolean;
|
|
76
|
+
}): Record<string, unknown>;
|
|
77
|
+
//# sourceMappingURL=YAMLBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YAMLBuilder.d.ts","sourceRoot":"","sources":["../../src/builders/YAMLBuilder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,eAAe,EACf,WAAW,EACX,aAAa,EACb,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAe;;IAY5B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKzC;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKrC;;OAEG;IACH,YAAY,CACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,MAAM,GACf,IAAI;IAeP;;OAEG;IACH,aAAa,CACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACvC,OAAO,CAAC,EAAE,MAAM,GACf,IAAI;IAOP;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAKnC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAIlD;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI;IAQzD;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAWlE;;OAEG;IACH,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAwBhC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsBxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAmBnB;;OAEG;IACH,KAAK,IAAI,IAAI;CAUd;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA0E1B"}
|