emerald-exchange 0.10.0__tar.gz
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.
- emerald_exchange-0.10.0/LICENSE +21 -0
- emerald_exchange-0.10.0/PKG-INFO +196 -0
- emerald_exchange-0.10.0/README.md +158 -0
- emerald_exchange-0.10.0/emerald_exchange/__init__.py +9 -0
- emerald_exchange-0.10.0/emerald_exchange/__main__.py +7 -0
- emerald_exchange-0.10.0/emerald_exchange/agent_server.py +94 -0
- emerald_exchange-0.10.0/emerald_exchange/backends.py +1044 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/__init__.py +1 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/mcp_crypto.py +94 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/mcp_debate.py +97 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/mcp_market_data.py +67 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/mcp_orders.py +109 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/mcp_portfolio.py +48 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/mcp_prediction_markets.py +100 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/mcp_risk.py +83 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/mcp_signals.py +60 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp/mcp_strategy.py +45 -0
- emerald_exchange-0.10.0/emerald_exchange/mcp_server.py +94 -0
- emerald_exchange-0.10.0/emerald_exchange/risk_guards.py +178 -0
- emerald_exchange-0.10.0/emerald_exchange.egg-info/PKG-INFO +196 -0
- emerald_exchange-0.10.0/emerald_exchange.egg-info/SOURCES.txt +29 -0
- emerald_exchange-0.10.0/emerald_exchange.egg-info/dependency_links.txt +1 -0
- emerald_exchange-0.10.0/emerald_exchange.egg-info/entry_points.txt +3 -0
- emerald_exchange-0.10.0/emerald_exchange.egg-info/requires.txt +28 -0
- emerald_exchange-0.10.0/emerald_exchange.egg-info/top_level.txt +5 -0
- emerald_exchange-0.10.0/pyproject.toml +45 -0
- emerald_exchange-0.10.0/setup.cfg +4 -0
- emerald_exchange-0.10.0/tests/conftest.py +32 -0
- emerald_exchange-0.10.0/tests/test_concept_parity.py +53 -0
- emerald_exchange-0.10.0/tests/test_init_dynamics.py +39 -0
- emerald_exchange-0.10.0/tests/test_startup.py +97 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Knuckles Team
|
|
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.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: emerald-exchange
|
|
3
|
+
Version: 0.10.0
|
|
4
|
+
Summary: Emerald Exchange — Unified Finance MCP Server with fully abstracted exchange backends for equities, crypto, and derivatives trading. CONCEPT:EE-001
|
|
5
|
+
Author-email: Audel Rouhi <knucklessg1@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: agent-utilities[mcp]>=0.34.0
|
|
16
|
+
Requires-Dist: numpy>=1.24.0
|
|
17
|
+
Requires-Dist: pandas>=2.0.0
|
|
18
|
+
Provides-Extra: alpaca
|
|
19
|
+
Requires-Dist: alpaca-py>=0.30.0; extra == "alpaca"
|
|
20
|
+
Provides-Extra: binance
|
|
21
|
+
Requires-Dist: python-binance>=1.0.0; extra == "binance"
|
|
22
|
+
Provides-Extra: crypto
|
|
23
|
+
Requires-Dist: ccxt>=4.0.0; extra == "crypto"
|
|
24
|
+
Provides-Extra: prediction-markets
|
|
25
|
+
Requires-Dist: httpx>=0.24.0; extra == "prediction-markets"
|
|
26
|
+
Requires-Dist: kalshi-python; extra == "prediction-markets"
|
|
27
|
+
Requires-Dist: py-clob-client; extra == "prediction-markets"
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: agent-utilities[agent,logfire,mcp]>=0.34.0; extra == "all"
|
|
30
|
+
Requires-Dist: alpaca-py>=0.30.0; extra == "all"
|
|
31
|
+
Requires-Dist: ccxt>=4.0.0; extra == "all"
|
|
32
|
+
Requires-Dist: httpx>=0.24.0; extra == "all"
|
|
33
|
+
Requires-Dist: kalshi-python; extra == "all"
|
|
34
|
+
Requires-Dist: py-clob-client; extra == "all"
|
|
35
|
+
Provides-Extra: agent
|
|
36
|
+
Requires-Dist: agent-utilities[agent,logfire]>=0.34.0; extra == "agent"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# Emerald Exchange - API | MCP | A2A
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+

|
|
43
|
+
|
|
44
|
+
*Version: 0.10.0*
|
|
45
|
+
|
|
46
|
+
## Overview
|
|
47
|
+
|
|
48
|
+
Emerald Exchange is a unified Finance MCP Server providing fully abstracted exchange backends
|
|
49
|
+
for equities, crypto, and derivatives trading. All trading functionality is tool-driven via MCP,
|
|
50
|
+
with built-in financial hardening controls (OS-5.1).
|
|
51
|
+
|
|
52
|
+
**Key Features:**
|
|
53
|
+
- **5 Exchange Backends**: Paper (default), Alpaca (FREE), CCXT (100+ exchanges), Freqtrade
|
|
54
|
+
- **6 MCP Tool Domains**: market-data, orders, portfolio, risk, signals, strategy
|
|
55
|
+
- **Financial Hardening**: Paper-first default, Kelly criterion position sizing, circuit breakers, kill switch
|
|
56
|
+
- **Config-Driven**: All settings via `~/.config/agent-utilities/config.json`
|
|
57
|
+
|
|
58
|
+
## Architecture
|
|
59
|
+
|
|
60
|
+
```mermaid
|
|
61
|
+
flowchart TB
|
|
62
|
+
A["Agent / IDE"] --> B["emerald-exchange MCP"]
|
|
63
|
+
B --> C["Risk Guard (OS-5.1)"]
|
|
64
|
+
C --> D{"Exchange Router"}
|
|
65
|
+
D --> E["Paper Backend (Default)"]
|
|
66
|
+
D --> F["Alpaca Backend (FREE)"]
|
|
67
|
+
D --> G["CCXT Backend (Binance/Coinbase/Kraken)"]
|
|
68
|
+
D --> H["Freqtrade Backend"]
|
|
69
|
+
|
|
70
|
+
style B fill:#10B981,stroke:#065F46,color:#fff
|
|
71
|
+
style C fill:#EF4444,stroke:#991B1B,color:#fff
|
|
72
|
+
style E fill:#6366F1,stroke:#4338CA,color:#fff
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## MCP Tools
|
|
76
|
+
|
|
77
|
+
| Domain | Tool Name | Actions | Tag |
|
|
78
|
+
|--------|-----------|---------|-----|
|
|
79
|
+
| Market Data | `emerald_market_data` | quote, historical, exchanges | market-data |
|
|
80
|
+
| Orders | `emerald_orders` | submit, cancel, status, halt, resume | orders |
|
|
81
|
+
| Portfolio | `emerald_portfolio` | positions, account | portfolio |
|
|
82
|
+
| Prediction Markets | `emerald_prediction_markets` | kalshi_events, polymarket_events, open_meteo_ensemble | prediction-markets |
|
|
83
|
+
| Risk | `emerald_risk` | status, drawdown_check, daily_loss_check, kelly, limits | risk |
|
|
84
|
+
| Signals | `emerald_signals` | regime, alpha, fuse | signals |
|
|
85
|
+
| Strategy | `emerald_strategy` | list, promote, export | strategy |
|
|
86
|
+
|
|
87
|
+
## Exchange Backends
|
|
88
|
+
|
|
89
|
+
| Backend | Assets | Paper | Live | Free |
|
|
90
|
+
|---------|--------|-------|------|------|
|
|
91
|
+
| Paper | All | ✅ | — | ✅ |
|
|
92
|
+
| Alpaca | Equities, Crypto | ✅ | ✅ | ✅ |
|
|
93
|
+
| CCXT (Binance) | Crypto | ✅ | ✅ | ✅ |
|
|
94
|
+
| CCXT (Coinbase) | Crypto | ✅ | ✅ | ✅ |
|
|
95
|
+
| CCXT (Kraken) | Crypto | ✅ | ✅ | ✅ |
|
|
96
|
+
| Freqtrade | Crypto | ✅ | ✅ | ✅ |
|
|
97
|
+
| Prediction Markets (Kalshi/Polymarket) | Events/Weather | ✅ | ✅ | ✅ |
|
|
98
|
+
|
|
99
|
+
## Financial Hardening (OS-5.1)
|
|
100
|
+
|
|
101
|
+
| Control | Default |
|
|
102
|
+
|---------|---------|
|
|
103
|
+
| Trading Mode | Paper (must explicitly opt into live) |
|
|
104
|
+
| Max Position Size | 2% of portfolio (Kelly criterion) |
|
|
105
|
+
| Max Portfolio Drawdown | 10% auto-halt |
|
|
106
|
+
| Max Daily Loss | 3% auto-halt |
|
|
107
|
+
| Regime Shift Detection | KS-test auto-halt |
|
|
108
|
+
| Human Approval for Live | Required |
|
|
109
|
+
| Kill Switch | `emerald_orders(action="halt")` |
|
|
110
|
+
|
|
111
|
+
## Usage
|
|
112
|
+
|
|
113
|
+
### MCP Configuration
|
|
114
|
+
|
|
115
|
+
#### stdio Mode
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"mcpServers": {
|
|
119
|
+
"emerald-exchange": {
|
|
120
|
+
"command": "uv",
|
|
121
|
+
"args": ["run", "--with", "emerald-exchange", "emerald-exchange"],
|
|
122
|
+
"env": {}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Streamable HTTP Mode
|
|
129
|
+
```bash
|
|
130
|
+
emerald-exchange --transport streamable-http --port 8100
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Configuration
|
|
134
|
+
|
|
135
|
+
All trading settings are configured via `~/.config/agent-utilities/config.json`:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"trading": {
|
|
140
|
+
"default_mode": "paper",
|
|
141
|
+
"default_exchange": "alpaca",
|
|
142
|
+
"exchanges": {
|
|
143
|
+
"alpaca": {
|
|
144
|
+
"enabled": true,
|
|
145
|
+
"api_key_env": "ALPACA_API_KEY",
|
|
146
|
+
"api_secret_env": "ALPACA_SECRET_KEY",
|
|
147
|
+
"base_url": "https://paper-api.alpaca.markets"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"risk_limits": {
|
|
151
|
+
"max_position_pct": 0.02,
|
|
152
|
+
"max_portfolio_drawdown_pct": 0.10,
|
|
153
|
+
"max_daily_loss_pct": 0.03,
|
|
154
|
+
"require_human_approval_live": true
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## ⚙️ Dynamic Tool Selection & Visibility
|
|
161
|
+
|
|
162
|
+
This MCP server supports dynamic toolset selection and visibility filtering at runtime. This allows you to restrict the set of exposed tools in order to prevent blowing up the LLM's context window.
|
|
163
|
+
|
|
164
|
+
You can configure tool filtering via multiple input channels:
|
|
165
|
+
|
|
166
|
+
- **CLI Arguments:** Pass `--tools` or `--toolsets` (or their disabled counterparts `--disabled-tools` and `--disabled-toolsets`) during startup.
|
|
167
|
+
- **Environment Variables:** Define standard environment variables:
|
|
168
|
+
- `MCP_ENABLED_TOOLS` / `MCP_DISABLED_TOOLS`
|
|
169
|
+
- `MCP_ENABLED_TAGS` / `MCP_DISABLED_TAGS`
|
|
170
|
+
- **HTTP SSE Request Headers:** Pass custom headers during transport initialization:
|
|
171
|
+
- `x-mcp-enabled-tools` / `x-mcp-disabled-tools`
|
|
172
|
+
- `x-mcp-enabled-tags` / `x-mcp-disabled-tags`
|
|
173
|
+
- **HTTP SSE Request Query Parameters:** Append query parameters directly to your transport connection URL:
|
|
174
|
+
- `?tools=tool1,tool2`
|
|
175
|
+
- `?tags=tag1`
|
|
176
|
+
|
|
177
|
+
When query strings or parameters are supplied, an LLM-free **Knowledge Graph resolution layer** (using `DynamicToolOrchestrator`) matches query intents against known tool tags, names, or descriptions, with safe fallback and automated 24-hour background cache refreshing.
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Installation
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
pip install emerald-exchange # Core + paper backend
|
|
186
|
+
pip install emerald-exchange[alpaca] # + Alpaca equities
|
|
187
|
+
pip install emerald-exchange[crypto] # + CCXT crypto
|
|
188
|
+
pip install emerald-exchange[prediction_markets] # + Kalshi & Polymarket
|
|
189
|
+
pip install emerald-exchange[all] # Everything
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Docker
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
docker compose -f docker/compose.yml up -d
|
|
196
|
+
```
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Emerald Exchange - API | MCP | A2A
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
*Version: 0.10.0*
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Emerald Exchange is a unified Finance MCP Server providing fully abstracted exchange backends
|
|
11
|
+
for equities, crypto, and derivatives trading. All trading functionality is tool-driven via MCP,
|
|
12
|
+
with built-in financial hardening controls (OS-5.1).
|
|
13
|
+
|
|
14
|
+
**Key Features:**
|
|
15
|
+
- **5 Exchange Backends**: Paper (default), Alpaca (FREE), CCXT (100+ exchanges), Freqtrade
|
|
16
|
+
- **6 MCP Tool Domains**: market-data, orders, portfolio, risk, signals, strategy
|
|
17
|
+
- **Financial Hardening**: Paper-first default, Kelly criterion position sizing, circuit breakers, kill switch
|
|
18
|
+
- **Config-Driven**: All settings via `~/.config/agent-utilities/config.json`
|
|
19
|
+
|
|
20
|
+
## Architecture
|
|
21
|
+
|
|
22
|
+
```mermaid
|
|
23
|
+
flowchart TB
|
|
24
|
+
A["Agent / IDE"] --> B["emerald-exchange MCP"]
|
|
25
|
+
B --> C["Risk Guard (OS-5.1)"]
|
|
26
|
+
C --> D{"Exchange Router"}
|
|
27
|
+
D --> E["Paper Backend (Default)"]
|
|
28
|
+
D --> F["Alpaca Backend (FREE)"]
|
|
29
|
+
D --> G["CCXT Backend (Binance/Coinbase/Kraken)"]
|
|
30
|
+
D --> H["Freqtrade Backend"]
|
|
31
|
+
|
|
32
|
+
style B fill:#10B981,stroke:#065F46,color:#fff
|
|
33
|
+
style C fill:#EF4444,stroke:#991B1B,color:#fff
|
|
34
|
+
style E fill:#6366F1,stroke:#4338CA,color:#fff
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## MCP Tools
|
|
38
|
+
|
|
39
|
+
| Domain | Tool Name | Actions | Tag |
|
|
40
|
+
|--------|-----------|---------|-----|
|
|
41
|
+
| Market Data | `emerald_market_data` | quote, historical, exchanges | market-data |
|
|
42
|
+
| Orders | `emerald_orders` | submit, cancel, status, halt, resume | orders |
|
|
43
|
+
| Portfolio | `emerald_portfolio` | positions, account | portfolio |
|
|
44
|
+
| Prediction Markets | `emerald_prediction_markets` | kalshi_events, polymarket_events, open_meteo_ensemble | prediction-markets |
|
|
45
|
+
| Risk | `emerald_risk` | status, drawdown_check, daily_loss_check, kelly, limits | risk |
|
|
46
|
+
| Signals | `emerald_signals` | regime, alpha, fuse | signals |
|
|
47
|
+
| Strategy | `emerald_strategy` | list, promote, export | strategy |
|
|
48
|
+
|
|
49
|
+
## Exchange Backends
|
|
50
|
+
|
|
51
|
+
| Backend | Assets | Paper | Live | Free |
|
|
52
|
+
|---------|--------|-------|------|------|
|
|
53
|
+
| Paper | All | ✅ | — | ✅ |
|
|
54
|
+
| Alpaca | Equities, Crypto | ✅ | ✅ | ✅ |
|
|
55
|
+
| CCXT (Binance) | Crypto | ✅ | ✅ | ✅ |
|
|
56
|
+
| CCXT (Coinbase) | Crypto | ✅ | ✅ | ✅ |
|
|
57
|
+
| CCXT (Kraken) | Crypto | ✅ | ✅ | ✅ |
|
|
58
|
+
| Freqtrade | Crypto | ✅ | ✅ | ✅ |
|
|
59
|
+
| Prediction Markets (Kalshi/Polymarket) | Events/Weather | ✅ | ✅ | ✅ |
|
|
60
|
+
|
|
61
|
+
## Financial Hardening (OS-5.1)
|
|
62
|
+
|
|
63
|
+
| Control | Default |
|
|
64
|
+
|---------|---------|
|
|
65
|
+
| Trading Mode | Paper (must explicitly opt into live) |
|
|
66
|
+
| Max Position Size | 2% of portfolio (Kelly criterion) |
|
|
67
|
+
| Max Portfolio Drawdown | 10% auto-halt |
|
|
68
|
+
| Max Daily Loss | 3% auto-halt |
|
|
69
|
+
| Regime Shift Detection | KS-test auto-halt |
|
|
70
|
+
| Human Approval for Live | Required |
|
|
71
|
+
| Kill Switch | `emerald_orders(action="halt")` |
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
### MCP Configuration
|
|
76
|
+
|
|
77
|
+
#### stdio Mode
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"emerald-exchange": {
|
|
82
|
+
"command": "uv",
|
|
83
|
+
"args": ["run", "--with", "emerald-exchange", "emerald-exchange"],
|
|
84
|
+
"env": {}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Streamable HTTP Mode
|
|
91
|
+
```bash
|
|
92
|
+
emerald-exchange --transport streamable-http --port 8100
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Configuration
|
|
96
|
+
|
|
97
|
+
All trading settings are configured via `~/.config/agent-utilities/config.json`:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"trading": {
|
|
102
|
+
"default_mode": "paper",
|
|
103
|
+
"default_exchange": "alpaca",
|
|
104
|
+
"exchanges": {
|
|
105
|
+
"alpaca": {
|
|
106
|
+
"enabled": true,
|
|
107
|
+
"api_key_env": "ALPACA_API_KEY",
|
|
108
|
+
"api_secret_env": "ALPACA_SECRET_KEY",
|
|
109
|
+
"base_url": "https://paper-api.alpaca.markets"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"risk_limits": {
|
|
113
|
+
"max_position_pct": 0.02,
|
|
114
|
+
"max_portfolio_drawdown_pct": 0.10,
|
|
115
|
+
"max_daily_loss_pct": 0.03,
|
|
116
|
+
"require_human_approval_live": true
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## ⚙️ Dynamic Tool Selection & Visibility
|
|
123
|
+
|
|
124
|
+
This MCP server supports dynamic toolset selection and visibility filtering at runtime. This allows you to restrict the set of exposed tools in order to prevent blowing up the LLM's context window.
|
|
125
|
+
|
|
126
|
+
You can configure tool filtering via multiple input channels:
|
|
127
|
+
|
|
128
|
+
- **CLI Arguments:** Pass `--tools` or `--toolsets` (or their disabled counterparts `--disabled-tools` and `--disabled-toolsets`) during startup.
|
|
129
|
+
- **Environment Variables:** Define standard environment variables:
|
|
130
|
+
- `MCP_ENABLED_TOOLS` / `MCP_DISABLED_TOOLS`
|
|
131
|
+
- `MCP_ENABLED_TAGS` / `MCP_DISABLED_TAGS`
|
|
132
|
+
- **HTTP SSE Request Headers:** Pass custom headers during transport initialization:
|
|
133
|
+
- `x-mcp-enabled-tools` / `x-mcp-disabled-tools`
|
|
134
|
+
- `x-mcp-enabled-tags` / `x-mcp-disabled-tags`
|
|
135
|
+
- **HTTP SSE Request Query Parameters:** Append query parameters directly to your transport connection URL:
|
|
136
|
+
- `?tools=tool1,tool2`
|
|
137
|
+
- `?tags=tag1`
|
|
138
|
+
|
|
139
|
+
When query strings or parameters are supplied, an LLM-free **Knowledge Graph resolution layer** (using `DynamicToolOrchestrator`) matches query intents against known tool tags, names, or descriptions, with safe fallback and automated 24-hour background cache refreshing.
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Installation
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pip install emerald-exchange # Core + paper backend
|
|
148
|
+
pip install emerald-exchange[alpaca] # + Alpaca equities
|
|
149
|
+
pip install emerald-exchange[crypto] # + CCXT crypto
|
|
150
|
+
pip install emerald-exchange[prediction_markets] # + Kalshi & Polymarket
|
|
151
|
+
pip install emerald-exchange[all] # Everything
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Docker
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
docker compose -f docker/compose.yml up -d
|
|
158
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Emerald Exchange — Unified Finance MCP Server.
|
|
2
|
+
|
|
3
|
+
CONCEPT:EE-001 — Emerald Exchange Core
|
|
4
|
+
|
|
5
|
+
Provides fully abstracted exchange backends for equities, crypto, and
|
|
6
|
+
derivatives trading. All functionality is tool-driven via MCP.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__version__ = "0.10.0"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
# coding: utf-8
|
|
3
|
+
"""Emerald Exchange A2A Agent Server — CONCEPT:EE-017.
|
|
4
|
+
|
|
5
|
+
Launches the Emerald Exchange as a full Pydantic AI agent with A2A
|
|
6
|
+
(Agent-to-Agent) communication support, backed by the MCP toolset.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
import logging
|
|
12
|
+
import warnings
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
__version__ = "0.1.0"
|
|
16
|
+
|
|
17
|
+
logging.basicConfig(
|
|
18
|
+
level=logging.INFO,
|
|
19
|
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
20
|
+
handlers=[logging.StreamHandler()],
|
|
21
|
+
)
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
# Load identity and system prompt from workspace
|
|
25
|
+
DEFAULT_AGENT_NAME = None
|
|
26
|
+
DEFAULT_AGENT_DESCRIPTION = None
|
|
27
|
+
DEFAULT_AGENT_SYSTEM_PROMPT = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def agent_server():
|
|
31
|
+
from agent_utilities import (
|
|
32
|
+
build_system_prompt_from_workspace,
|
|
33
|
+
create_agent_parser,
|
|
34
|
+
create_agent_server,
|
|
35
|
+
initialize_workspace,
|
|
36
|
+
load_identity,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
global DEFAULT_AGENT_NAME, DEFAULT_AGENT_DESCRIPTION, DEFAULT_AGENT_SYSTEM_PROMPT
|
|
40
|
+
initialize_workspace()
|
|
41
|
+
meta = load_identity()
|
|
42
|
+
DEFAULT_AGENT_NAME = os.getenv(
|
|
43
|
+
"DEFAULT_AGENT_NAME", meta.get("name", "Emerald Exchange")
|
|
44
|
+
)
|
|
45
|
+
DEFAULT_AGENT_DESCRIPTION = os.getenv(
|
|
46
|
+
"AGENT_DESCRIPTION",
|
|
47
|
+
meta.get(
|
|
48
|
+
"description",
|
|
49
|
+
"Emerald Exchange — Unified Finance MCP with multi-exchange backend abstraction, "
|
|
50
|
+
"risk guards, and KG-native trading workflows. CONCEPT:EE-001",
|
|
51
|
+
),
|
|
52
|
+
)
|
|
53
|
+
DEFAULT_AGENT_SYSTEM_PROMPT = os.getenv(
|
|
54
|
+
"AGENT_SYSTEM_PROMPT",
|
|
55
|
+
meta.get("content") or build_system_prompt_from_workspace(),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
warnings.filterwarnings("ignore", message=".*urllib3.*or chardet.*")
|
|
59
|
+
warnings.filterwarnings("ignore", category=DeprecationWarning, module="fastmcp")
|
|
60
|
+
|
|
61
|
+
print(f"{DEFAULT_AGENT_NAME} v{__version__}", file=sys.stderr)
|
|
62
|
+
parser = create_agent_parser()
|
|
63
|
+
args = parser.parse_args()
|
|
64
|
+
|
|
65
|
+
if args.debug:
|
|
66
|
+
logging.getLogger().setLevel(logging.DEBUG)
|
|
67
|
+
logger.debug("Debug mode enabled")
|
|
68
|
+
|
|
69
|
+
# Start server using the auto-discovery pattern (from mcp_config.json)
|
|
70
|
+
create_agent_server(
|
|
71
|
+
mcp_url=args.mcp_url,
|
|
72
|
+
mcp_config=args.mcp_config or "mcp_config.json",
|
|
73
|
+
host=args.host,
|
|
74
|
+
port=args.port,
|
|
75
|
+
provider=args.provider,
|
|
76
|
+
model_id=args.model_id,
|
|
77
|
+
router_model=args.model_id,
|
|
78
|
+
agent_model=args.model_id,
|
|
79
|
+
base_url=args.base_url,
|
|
80
|
+
api_key=args.api_key,
|
|
81
|
+
custom_skills_directory=args.custom_skills_directory,
|
|
82
|
+
enable_web_ui=args.web,
|
|
83
|
+
enable_otel=args.otel,
|
|
84
|
+
otel_endpoint=args.otel_endpoint,
|
|
85
|
+
otel_headers=args.otel_headers,
|
|
86
|
+
otel_public_key=args.otel_public_key,
|
|
87
|
+
otel_secret_key=args.otel_secret_key,
|
|
88
|
+
otel_protocol=args.otel_protocol,
|
|
89
|
+
debug=args.debug,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if __name__ == "__main__":
|
|
94
|
+
agent_server()
|