iflow-mcp_dlwjdtn535-mcp-bybit-server 0.1.4__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.
- __init__.py +0 -0
- config.py +23 -0
- iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/METADATA +246 -0
- iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/RECORD +9 -0
- iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/WHEEL +4 -0
- iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/entry_points.txt +2 -0
- iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/licenses/LICENSE +21 -0
- server.py +683 -0
- service.py +531 -0
__init__.py
ADDED
|
File without changes
|
config.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
|
|
5
|
+
load_dotenv(verbose=True)
|
|
6
|
+
|
|
7
|
+
logging.basicConfig(level=logging.INFO)
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
class Config:
|
|
11
|
+
MEMBER_ID = os.getenv("MEMBER_ID")
|
|
12
|
+
ACCESS_KEY = os.getenv("ACCESS_KEY")
|
|
13
|
+
SECRET_KEY = os.getenv("SECRET_KEY")
|
|
14
|
+
TESTNET = os.getenv("TESTNET", "False").lower() == "true"
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def log_config(cls):
|
|
18
|
+
logger.info(f"MEMBER_ID: {cls.MEMBER_ID}")
|
|
19
|
+
logger.info(f"ACCESS_KEY: {cls.ACCESS_KEY}")
|
|
20
|
+
logger.info(f"TESTNET: {cls.TESTNET}")
|
|
21
|
+
|
|
22
|
+
# Log configuration
|
|
23
|
+
Config.log_config()
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: iflow-mcp_dlwjdtn535-mcp-bybit-server
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: Bybit server for mcp
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Requires-Dist: mcp[cli]>=1.6.0
|
|
8
|
+
Requires-Dist: pybit>=2.4.0
|
|
9
|
+
Requires-Dist: python-dotenv>=0.19.0
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# MCP Bybit API Interface
|
|
13
|
+
[](https://smithery.ai/server/@dlwjdtn535/mcp-bybit-server)
|
|
14
|
+
[](https://buymeacoffee.com/dlwjdtn535)
|
|
15
|
+
|
|
16
|
+
Bybit MCP (Model Context Protocol) Server. Provides a convenient interface to interact with the Bybit API using MCP tools. Allows fetching market data, managing account information, and placing/canceling orders via API calls wrapped as tools.
|
|
17
|
+
|
|
18
|
+
<a href="https://glama.ai/mcp/servers/@dlwjdtn535/mcp-bybit-server">
|
|
19
|
+
<img width="380" height="200" src="https://glama.ai/mcp/servers/@dlwjdtn535/mcp-bybit-server/badge" alt="Bybit Server MCP server" />
|
|
20
|
+
</a>
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Installing via Smithery
|
|
25
|
+
|
|
26
|
+
To install this Bybit API Interface server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@dlwjdtn535/mcp-bybit-server):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx -y @smithery/cli install @dlwjdtn535/mcp-bybit-server --client claude
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Using with Claude, Roo Code, Cline, etc.
|
|
33
|
+
|
|
34
|
+
Add the following configuration to your MCP settings file (e.g., `mcp_settings.json`):
|
|
35
|
+
**Using uv With Windows:**
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"mcp-server-demo": {
|
|
41
|
+
"command": "uv",
|
|
42
|
+
"args": [
|
|
43
|
+
"run",
|
|
44
|
+
"--directory",
|
|
45
|
+
"C:\\Users\\YOUR_USERNAME\\AppData\\Local\\Programs\\mcp-server-demo\\src",
|
|
46
|
+
"server.py"
|
|
47
|
+
],
|
|
48
|
+
"env": {
|
|
49
|
+
"ACCESS_KEY": "{ACCESS_KEY}",
|
|
50
|
+
"SECRET_KEY": "{ACCESS_KEY}"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// ... other servers might be here ...
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
(Remember to replace YOUR_USERNAME and use double backslashes \\)
|
|
59
|
+
|
|
60
|
+
**Using uv With macOS:**
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"mcpServers": {
|
|
65
|
+
"mcp-server-demo": {
|
|
66
|
+
"command": "uv",
|
|
67
|
+
"args": [
|
|
68
|
+
"run",
|
|
69
|
+
"--directory",
|
|
70
|
+
"/usr/local/bin/mcp-server-demo/src",
|
|
71
|
+
"server.py"
|
|
72
|
+
],
|
|
73
|
+
"env": {
|
|
74
|
+
"ACCESS_KEY": "{ACCESS_KEY}",
|
|
75
|
+
"SECRET_KEY": "{ACCESS_KEY}"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// ... other servers might be here ...
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
(Replace YOUR_USERNAME if using ~/bin)
|
|
83
|
+
|
|
84
|
+
**Using uv With Linux:**
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"mcpServers": {
|
|
89
|
+
"mcp-server-demo": {
|
|
90
|
+
"command": "uv",
|
|
91
|
+
"args": [
|
|
92
|
+
"run",
|
|
93
|
+
"--directory",
|
|
94
|
+
"/home/YOUR_USERNAME/bin/mcp-server-demo/src",
|
|
95
|
+
"server.py"
|
|
96
|
+
],
|
|
97
|
+
"env": {
|
|
98
|
+
"ACCESS_KEY": "{ACCESS_KEY}",
|
|
99
|
+
"SECRET_KEY": "{ACCESS_KEY}"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// ... other servers might be here ...
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
**Using Docker (Requires Docker)**
|
|
109
|
+
|
|
110
|
+
Make sure you have pulled the image first: `docker pull dlwjdtn535/mcp-bybit-server:latest`
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"mcpServers": {
|
|
115
|
+
"bybit-server-docker": {
|
|
116
|
+
"command": "docker",
|
|
117
|
+
"args": [
|
|
118
|
+
"run",
|
|
119
|
+
"-i",
|
|
120
|
+
"--rm",
|
|
121
|
+
"--init",
|
|
122
|
+
"-e", "ACCESS_KEY={ACCESS_KEY}",
|
|
123
|
+
"-e", "SECRET_KEY={SECRET_KEY}",
|
|
124
|
+
"dlwjdtn535/mcp-bybit-server:latest"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Using Docker with .env (Requires Docker)**
|
|
132
|
+
|
|
133
|
+
Make sure you have pulled the image first: `docker pull dlwjdtn535/mcp-bybit-server:latest`
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"bybit-server-docker": {
|
|
139
|
+
"command": "/bin/sh",
|
|
140
|
+
"args": [
|
|
141
|
+
"-c",
|
|
142
|
+
"source .env && docker run -i --rm --init -e ACCESS_KEY=$BYBIT_API_KEY -e SECRET_KEY=$BYBIT_API_SECRET -e TESTNET=true dlwjdtn535/mcp-bybit-server:latest"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
> **Note**: Always use `@latest` or a specific version tag for both NPX and Docker to ensure you are using the intended version.
|
|
150
|
+
|
|
151
|
+
## Tools 🛠️
|
|
152
|
+
|
|
153
|
+
This MCP server provides the following tools for interacting with the Bybit API:
|
|
154
|
+
|
|
155
|
+
1. **`get_orderbook`**: Fetches order book information.
|
|
156
|
+
* Inputs: `category`, `symbol`, `limit` (optional)
|
|
157
|
+
* Returns: Order book details.
|
|
158
|
+
2. **`get_kline`**: Fetches K-line (candlestick) data.
|
|
159
|
+
* Inputs: `category`, `symbol`, `interval`, `start` (optional), `end` (optional), `limit` (optional)
|
|
160
|
+
* Returns: Candlestick data.
|
|
161
|
+
3. **`get_tickers`**: Fetches cryptocurrency ticker information.
|
|
162
|
+
* Inputs: `category`, `symbol`
|
|
163
|
+
* Returns: Ticker information.
|
|
164
|
+
4. **`get_wallet_balance`**: Fetches account balance.
|
|
165
|
+
* Inputs: `accountType`, `coin` (optional)
|
|
166
|
+
* Returns: Balance information.
|
|
167
|
+
5. **`get_positions`**: Fetches position information.
|
|
168
|
+
* Inputs: `category`, `symbol` (optional)
|
|
169
|
+
* Returns: Position information.
|
|
170
|
+
6. **`place_order`**: Places a limit or market order.
|
|
171
|
+
* Inputs: `category`, `symbol`, `side`, `orderType`, `qty`, `price` (optional for limit), `positionIdx` (optional for futures), and other optional parameters (e.g., `timeInForce`, `takeProfit`, `stopLoss`).
|
|
172
|
+
* Returns: Order placement confirmation.
|
|
173
|
+
7. **`cancel_order`**: Cancels an existing order.
|
|
174
|
+
* Inputs: `category`, `symbol`, `orderId` (optional), `orderLinkId` (optional)
|
|
175
|
+
* Returns: Cancellation confirmation.
|
|
176
|
+
8. **`get_order_history`**: Fetches historical order details.
|
|
177
|
+
* Inputs: `category`, `symbol` (optional), `orderId` (optional), `limit` (optional), etc.
|
|
178
|
+
* Returns: Order history.
|
|
179
|
+
9. **`get_open_orders`**: Fetches current open orders.
|
|
180
|
+
* Inputs: `category`, `symbol` (optional), `limit` (optional), etc.
|
|
181
|
+
* Returns: Open order details.
|
|
182
|
+
10. **`set_trading_stop`**: Sets take profit, stop loss, or trailing stop for a position.
|
|
183
|
+
* Inputs: `category`, `symbol`, `takeProfit` (optional), `stopLoss` (optional), `trailingStop` (optional), `positionIdx` (optional)
|
|
184
|
+
* Returns: Setting confirmation.
|
|
185
|
+
11. **`set_margin_mode`**: Sets the margin mode (isolated or cross).
|
|
186
|
+
* Inputs: `category`, `symbol`, `tradeMode`, `buyLeverage`, `sellLeverage`
|
|
187
|
+
* Returns: Setting confirmation.
|
|
188
|
+
12. **`get_api_key_information`**: Fetches information about the current API key.
|
|
189
|
+
* Inputs: None
|
|
190
|
+
* Returns: API key details.
|
|
191
|
+
13. **`get_instruments_info`**: Fetches details about trading instruments (symbols).
|
|
192
|
+
* Inputs: `category`, `symbol`, `status` (optional), `baseCoin` (optional)
|
|
193
|
+
* Returns: Instrument details.
|
|
194
|
+
|
|
195
|
+
_(Refer to the function docstrings in the code for detailed parameter descriptions and examples.)_
|
|
196
|
+
|
|
197
|
+
## Environment Variables
|
|
198
|
+
|
|
199
|
+
Before running the server, you **must** set the following environment variables:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
ACCESS_KEY=YOUR_BYBIT_API_KEY
|
|
203
|
+
SECRET_KEY=YOUR_BYBIT_SECRET_KEY
|
|
204
|
+
TESTNET=false # Optional: set to true for testnet
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## API Key Setup
|
|
208
|
+
|
|
209
|
+
To use this Bybit API interface, you need to create an API key from Bybit. Follow these important steps:
|
|
210
|
+
|
|
211
|
+
1. Go to Bybit and log into your account.
|
|
212
|
+
2. Navigate to API Management.
|
|
213
|
+
3. Create a new API key.
|
|
214
|
+
4. **Important Security Settings:**
|
|
215
|
+
* Enable IP restriction if possible.
|
|
216
|
+
* Add ONLY the IP address(es) from which the server will run (your local PC IP, server IP, or Docker container's external IP).
|
|
217
|
+
* Never share your API keys or expose them in public repositories.
|
|
218
|
+
* Recommended permissions:
|
|
219
|
+
* Read (Required)
|
|
220
|
+
* Trade (Required for order execution)
|
|
221
|
+
* Wallet (Required for balance checking)
|
|
222
|
+
|
|
223
|
+
## Sponsorship & Donations
|
|
224
|
+
|
|
225
|
+
If you find this project helpful and would like to support its development, you can contribute in the following ways:
|
|
226
|
+
|
|
227
|
+
### Buy Me a Coffee
|
|
228
|
+
[](https://buymeacoffee.com/dlwjdtn535)
|
|
229
|
+
|
|
230
|
+
### Referral Program
|
|
231
|
+
You can also support this project by signing up for Bybit using our referral link:
|
|
232
|
+
- [My Bybit Referral Link](https://www.bybit.com/invite?ref=J1O4JK)
|
|
233
|
+
- Referral Code: J1O4JK
|
|
234
|
+
|
|
235
|
+
Your support helps maintain and improve this project. Thank you! 🙏
|
|
236
|
+
|
|
237
|
+
## Contact & Support
|
|
238
|
+
|
|
239
|
+
For additional inquiries or support, please contact:
|
|
240
|
+
- Email: dlwjdtn5624@naver.com
|
|
241
|
+
|
|
242
|
+
We welcome your questions and feedback!
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT License
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
config.py,sha256=Lsk0bnvI-LqYFx918a_ElGj4OCFaa4wudkxgs06c72k,593
|
|
3
|
+
server.py,sha256=cbagq2VbrITxI80LXE-oYheKT0neDXvzF5vE0IYxmO4,28313
|
|
4
|
+
service.py,sha256=ehEjz-S8HX89i6S7VzJTrVaUYHojGBVGDYrsK_GyyoU,20610
|
|
5
|
+
iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/METADATA,sha256=EVJrrmKabCiUQsZiK3XiOzLE1yoKDO0xMiWb9vO5SRI,8098
|
|
6
|
+
iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
7
|
+
iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/entry_points.txt,sha256=42YsabYVHgiW6dNS0IMEZ6buvzLQXGpeBMgf5eKR5tU,49
|
|
8
|
+
iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/licenses/LICENSE,sha256=hHlGAEMgXrKdC2WKaY3ZR1D5ELEkYOrNbqbTDGKg7Do,1067
|
|
9
|
+
iflow_mcp_dlwjdtn535_mcp_bybit_server-0.1.4.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Dana K. Williams
|
|
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 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.
|