defistream-mcp 0.2.0__py3-none-any.whl
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.
- defistream_mcp/__init__.py +3 -0
- defistream_mcp/api_client.py +102 -0
- defistream_mcp/config.py +99 -0
- defistream_mcp/formatters.py +247 -0
- defistream_mcp/resources.py +65 -0
- defistream_mcp/server.py +61 -0
- defistream_mcp/tools.py +727 -0
- defistream_mcp-0.2.0.dist-info/METADATA +224 -0
- defistream_mcp-0.2.0.dist-info/RECORD +11 -0
- defistream_mcp-0.2.0.dist-info/WHEEL +4 -0
- defistream_mcp-0.2.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: defistream-mcp
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: MCP server for the DeFiStream API
|
|
5
|
+
Project-URL: Homepage, https://defistream.dev
|
|
6
|
+
Project-URL: Documentation, https://docs.defistream.dev
|
|
7
|
+
Project-URL: Repository, https://github.com/Eren-Nevin/DeFiStream_MCPServer
|
|
8
|
+
Author-email: DeFiStream <support@defistream.dev>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Keywords: blockchain,defi,llm,mcp,model-context-protocol
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: httpx>=0.25.0
|
|
21
|
+
Requires-Dist: mcp>=1.7.0
|
|
22
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest-xdist>=3.5.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# DeFiStream MCP Server
|
|
30
|
+
|
|
31
|
+
Model Context Protocol (MCP) server that wraps the [DeFiStream](https://defistream.dev) REST API, giving LLMs (Claude Desktop, Claude Code, etc.) direct access to on-chain DeFi event data. Make sure to get an api key from app.defistream.deveasily.
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Install
|
|
37
|
+
cd mcp-server
|
|
38
|
+
pip install -e .
|
|
39
|
+
|
|
40
|
+
# Set your API key
|
|
41
|
+
export DEFISTREAM_API_KEY="dsk_your_key_here"
|
|
42
|
+
|
|
43
|
+
# Run (stdio transport)
|
|
44
|
+
defistream-mcp
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Docker
|
|
48
|
+
|
|
49
|
+
No Python installation required — run the MCP server directly from Docker Hub:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
docker run -i -e DEFISTREAM_API_KEY=dsk_your_key_here defistream/mcp-server
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Claude Code
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
claude mcp add --transport stdio defistream \
|
|
59
|
+
-- docker run -i -e DEFISTREAM_API_KEY=dsk_your_key_here defistream/mcp-server
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Claude Desktop (Docker)
|
|
63
|
+
|
|
64
|
+
Add to `claude_desktop_config.json`:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"defistream": {
|
|
70
|
+
"command": "docker",
|
|
71
|
+
"args": [
|
|
72
|
+
"run", "-i",
|
|
73
|
+
"-e", "DEFISTREAM_API_KEY=dsk_your_key_here",
|
|
74
|
+
"defistream/mcp-server"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
> **Note:** Claude Desktop passes `env` to the spawned process, but `docker run` requires explicit `-e` flags. Put the API key in `args` as shown above, or set it in your shell before launching Claude Desktop.
|
|
82
|
+
|
|
83
|
+
### Build from Source
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
cd mcp-server
|
|
87
|
+
docker build -t defistream/mcp-server .
|
|
88
|
+
docker run -i -e DEFISTREAM_API_KEY=dsk_your_key_here defistream/mcp-server
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Publish to Docker Hub
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
docker login
|
|
95
|
+
docker build -t defistream/mcp-server:latest -t defistream/mcp-server:0.1.0 .
|
|
96
|
+
docker push defistream/mcp-server:latest
|
|
97
|
+
docker push defistream/mcp-server:0.1.0
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Claude Desktop Configuration
|
|
101
|
+
|
|
102
|
+
Add to your `claude_desktop_config.json`:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"defistream": {
|
|
108
|
+
"command": "defistream-mcp",
|
|
109
|
+
"env": {
|
|
110
|
+
"DEFISTREAM_API_KEY": "dsk_your_key_here"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Environment Variables
|
|
118
|
+
|
|
119
|
+
| Variable | Required | Default | Description |
|
|
120
|
+
|---|---|---|---|
|
|
121
|
+
| `DEFISTREAM_API_KEY` | Yes | — | API key (`dsk_xxx`) |
|
|
122
|
+
| `DEFISTREAM_LOCAL` | No | `false` | Set to `true` to use local gateway (`http://localhost:8081/v1`) |
|
|
123
|
+
| `DEFISTREAM_BASE_URL` | No | `https://api.defistream.dev/v1` | API base URL (overrides `DEFISTREAM_LOCAL`) |
|
|
124
|
+
| `DEFISTREAM_MCP_TRANSPORT` | No | `stdio` | `stdio` or `sse` |
|
|
125
|
+
| `DEFISTREAM_DOWNLOAD_DIR` | No | `.` (cwd) | Default dir for downloaded files |
|
|
126
|
+
| `DEFISTREAM_QUERY_ROW_LIMIT` | No | `200` | Max rows returned by execute_query |
|
|
127
|
+
|
|
128
|
+
### Local Development
|
|
129
|
+
|
|
130
|
+
To test against the local API gateway (port 8081):
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
export DEFISTREAM_API_KEY="dsk_your_key"
|
|
134
|
+
export DEFISTREAM_LOCAL=true
|
|
135
|
+
defistream-mcp
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Or in Claude Desktop / Claude Code config:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"mcpServers": {
|
|
143
|
+
"defistream": {
|
|
144
|
+
"command": "defistream-mcp",
|
|
145
|
+
"env": {
|
|
146
|
+
"DEFISTREAM_API_KEY": "dsk_your_key",
|
|
147
|
+
"DEFISTREAM_LOCAL": "true"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Tools
|
|
155
|
+
|
|
156
|
+
### Utility
|
|
157
|
+
|
|
158
|
+
| Tool | Description |
|
|
159
|
+
|---|---|
|
|
160
|
+
| `supported_networks(protocol)` | List supported networks for a protocol |
|
|
161
|
+
| `supported_events(protocol)` | List supported event types for a protocol |
|
|
162
|
+
| `base_url()` | Get the API base URL |
|
|
163
|
+
| `execute_query(query, limit?)` | Execute a query path and return JSON results |
|
|
164
|
+
| `download_query(query, file_format?, output_dir?)` | Download query results as CSV/Parquet |
|
|
165
|
+
|
|
166
|
+
### Protocol Query Builders
|
|
167
|
+
|
|
168
|
+
Each builder returns a query path string to pass to `execute_query()` or `download_query()`.
|
|
169
|
+
|
|
170
|
+
| Tool | Protocol | Required Params |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `erc20_query_builder` | ERC-20 tokens | `event_type`, `network`, `token` |
|
|
173
|
+
| `native_token_query_builder` | Native tokens (ETH, BNB, …) | `event_type`, `network` |
|
|
174
|
+
| `aave_v3_query_builder` | AAVE V3 lending | `event_type`, `network` |
|
|
175
|
+
| `uniswap_v3_query_builder` | Uniswap V3 DEX | `event_type`, `network`, `symbol0`, `symbol1`, `fee` |
|
|
176
|
+
| `lido_query_builder` | Lido staking | `event_type`, `network` |
|
|
177
|
+
| `stader_query_builder` | Stader ETHx | `event_type`, `network` |
|
|
178
|
+
| `threshold_query_builder` | Threshold tBTC | `event_type`, `network` |
|
|
179
|
+
|
|
180
|
+
All builders also accept: `block_start/block_end` or `since/until` for range, `verbose`, `with_value`, `aggregate`, `group_by`, `period`, and protocol-specific filter params.
|
|
181
|
+
|
|
182
|
+
- **`with_value`** — Set `true` to enrich events with USD value data. Adds `value_usd` column to individual events, and `agg_value_usd` to aggregate results.
|
|
183
|
+
|
|
184
|
+
### Workflow
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
1. supported_networks("erc20") → check network is valid
|
|
188
|
+
2. erc20_query_builder( → build query path
|
|
189
|
+
event_type="transfer",
|
|
190
|
+
network="ETH",
|
|
191
|
+
token="USDT",
|
|
192
|
+
since="2025-01-01",
|
|
193
|
+
until="2025-01-02"
|
|
194
|
+
)
|
|
195
|
+
3. execute_query(query) → get JSON results
|
|
196
|
+
— or —
|
|
197
|
+
download_query(query, "csv") → save CSV file
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Multi-token queries:** Pass comma-separated known symbol names to query multiple tokens at once (contract addresses not supported for multi-token):
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
erc20_query_builder(
|
|
204
|
+
event_type="transfer",
|
|
205
|
+
network="ETH",
|
|
206
|
+
token="USDT,USDC,DAI",
|
|
207
|
+
since="2025-01-01",
|
|
208
|
+
until="2025-01-02"
|
|
209
|
+
)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Resources
|
|
213
|
+
|
|
214
|
+
| URI | Description |
|
|
215
|
+
|---|---|
|
|
216
|
+
| `defistream://protocols` | Protocol descriptions and builder tool mapping |
|
|
217
|
+
| `defistream://api-limits` | Block limits, row caps, quota info |
|
|
218
|
+
|
|
219
|
+
## Development
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
pip install -e ".[dev]"
|
|
223
|
+
pytest
|
|
224
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
defistream_mcp/__init__.py,sha256=yOeKNMa4Vamk7c_E1i5hh8T5e_PHeWsyF8uSmiRH7zk,109
|
|
2
|
+
defistream_mcp/api_client.py,sha256=jhr4Mm8gHwPldpJdWwxx2xDZR4lI-Z8DYplciWtGBcU,3306
|
|
3
|
+
defistream_mcp/config.py,sha256=fY_PX6_OUcZHFdfsG8jfdw_iFqhlyZLSpjIvfqCzfXw,3708
|
|
4
|
+
defistream_mcp/formatters.py,sha256=XUMPCw7f0I7EPToq3-IdEmxbfdIDXuLyZn78NOInmGE,6793
|
|
5
|
+
defistream_mcp/resources.py,sha256=A0XTXPFhYn2X0dI1SzCngmSSkoTVLWCuMo-Az0ySwDQ,2608
|
|
6
|
+
defistream_mcp/server.py,sha256=Dw5XDbCq8W5-OZPaW8okrAMu9OolfYQUZPLMvVO4MDw,1682
|
|
7
|
+
defistream_mcp/tools.py,sha256=FkHwTfwWBEK4PSOfGehJU_9zOmewdxtmul4Yga1iSGQ,30222
|
|
8
|
+
defistream_mcp-0.2.0.dist-info/METADATA,sha256=FR-4nPc6YIHQataXIYGFpj8C-JDU1Z1RUTobGKWNV7w,6522
|
|
9
|
+
defistream_mcp-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
+
defistream_mcp-0.2.0.dist-info/entry_points.txt,sha256=b8vx7j6914vBBpqa5X2TUgmppjNGQCpBMcpP6yEZhNk,62
|
|
11
|
+
defistream_mcp-0.2.0.dist-info/RECORD,,
|