alpaca-mcp-server 1.0.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.
@@ -0,0 +1,2 @@
1
+ .env
2
+ .gitignore
@@ -0,0 +1,12 @@
1
+ # This is an example of a .env file
2
+ # Alpaca API credentials
3
+ # Get these from https://app.alpaca.markets/paper/dashboard/overview
4
+ # Please change the following to your own PAPER api key and secret
5
+ ALPACA_API_KEY = "your_alpaca_api_key_for_paper_account"
6
+ ALPACA_SECRET_KEY = "your_alpaca_secret_key_for_paper_account"
7
+ ALPACA_PAPER_TRADE = True # True for paper trading, False for live trading
8
+
9
+ TRADE_API_URL = None
10
+ TRADE_API_WSS = None
11
+ DATA_API_URL = None
12
+ STREAM_DATA_WSS = None
@@ -0,0 +1,7 @@
1
+ USER_AGENT = "ALPACA-MCP-SERVER"
2
+
3
+ class UserAgentMixin:
4
+ def _get_default_headers(self) -> dict:
5
+ headers = self._get_auth_headers()
6
+ headers["User-Agent"] = USER_AGENT
7
+ return headers
@@ -0,0 +1,22 @@
1
+ name: 'Close stale issues and PRs'
2
+ on:
3
+ schedule:
4
+ - cron: '30 1 * * *'
5
+
6
+
7
+ jobs:
8
+ stale:
9
+ permissions:
10
+ pull-requests: write
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/stale@v9
14
+ with:
15
+ stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
16
+ stale-pr-message: 'This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
17
+ close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
18
+ close-pr-message: 'This PR was closed because it has been stalled for 5 days with no activity.'
19
+ days-before-issue-stale: -1
20
+ days-before-pr-stale: 14
21
+ days-before-issue-close: -1
22
+ days-before-pr-close: 5
@@ -0,0 +1,27 @@
1
+ # Environment and secrets
2
+ .env
3
+ .env.local
4
+ *.secret
5
+ secret.py
6
+
7
+ # Python
8
+ __pycache__/
9
+ *.py[cod]
10
+ *.so
11
+ .Python
12
+ env/
13
+ venv/
14
+ .venv/
15
+
16
+ # IDE
17
+ .vscode/
18
+ .idea/
19
+ *.swp
20
+ *.swo
21
+
22
+ # OS
23
+ .DS_Store
24
+ Thumbs.db
25
+
26
+ # Project-specific
27
+ _collection/
@@ -0,0 +1,359 @@
1
+ {
2
+ "_comment": "GitHub MCP Registry Manifest - Complete Tool Definitions",
3
+ "_location": "/.well-known/mcp/manifest.json",
4
+ "_purpose": "Metadata for GitHub MCP Registry listing and tool discovery",
5
+
6
+ "version": "1.0.0",
7
+ "schema_version": "0.1.0",
8
+ "name": "alpaca-mcp-server",
9
+ "display_name": "Alpaca MCP Server",
10
+ "description": "Comprehensive Alpaca Trading API integration for Model Context Protocol, enabling natural language trading operations through AI assistants",
11
+ "author": "Alpaca",
12
+ "license": "Apache-2.0",
13
+ "homepage": "https://alpaca.markets/",
14
+ "repository": "https://github.com/alpacahq/alpaca-mcp-server",
15
+ "documentation": "https://github.com/alpacahq/alpaca-mcp-server#readme",
16
+ "categories": ["finance", "trading", "data", "api"],
17
+ "tags": ["alpaca", "stocks", "options", "crypto", "portfolio", "market-data"],
18
+
19
+ "installation": {
20
+ "uvx": "alpaca-mcp-server",
21
+ "pypi": "alpaca-mcp-server",
22
+ "github": "git+https://github.com/alpacahq/alpaca-mcp-server.git"
23
+ },
24
+
25
+ "configuration": {
26
+ "required_env_vars": [
27
+ {
28
+ "name": "ALPACA_API_KEY",
29
+ "description": "Alpaca API key for trading account access",
30
+ "sensitive": true
31
+ },
32
+ {
33
+ "name": "ALPACA_SECRET_KEY",
34
+ "description": "Alpaca secret key for trading account access",
35
+ "sensitive": true
36
+ }
37
+ ],
38
+ "optional_env_vars": [
39
+ {
40
+ "name": "ALPACA_PAPER_TRADE",
41
+ "description": "Use paper trading mode (default: True)",
42
+ "default": "True"
43
+ }
44
+ ]
45
+ },
46
+
47
+ "tools": [
48
+ {
49
+ "name": "get_account_info",
50
+ "description": "Retrieves current account information including balances, buying power, and account status",
51
+ "parameters": {}
52
+ },
53
+ {
54
+ "name": "get_positions",
55
+ "description": "Retrieves all current positions in the portfolio with details like quantity, market value, and P&L",
56
+ "parameters": {}
57
+ },
58
+ {
59
+ "name": "get_open_position",
60
+ "description": "Retrieves detailed information for a specific open position",
61
+ "parameters": {
62
+ "symbol": {"type": "string", "required": true, "description": "The symbol name of the asset (e.g., 'AAPL', 'MSFT')"}
63
+ }
64
+ },
65
+ {
66
+ "name": "get_stock_quote",
67
+ "description": "Retrieves the latest quote for a stock including bid/ask prices and volumes",
68
+ "parameters": {
69
+ "symbol": {"type": "string", "required": true, "description": "Stock ticker symbol (e.g., AAPL, MSFT)"}
70
+ }
71
+ },
72
+ {
73
+ "name": "get_stock_bars",
74
+ "description": "Retrieves historical stock price bars (OHLCV data) with flexible timeframes",
75
+ "parameters": {
76
+ "symbol": {"type": "string", "required": true, "description": "Stock ticker symbol"},
77
+ "days": {"type": "integer", "required": false, "description": "Number of days of history (default: 5)"},
78
+ "timeframe": {"type": "string", "required": false, "description": "Bar timeframe: 1Min, 5Min, 1Hour, 1Day, etc. (default: 1Day)"},
79
+ "limit": {"type": "integer", "required": false, "description": "Maximum number of bars to return"},
80
+ "start": {"type": "string", "required": false, "description": "Start date in YYYY-MM-DD format"},
81
+ "end": {"type": "string", "required": false, "description": "End date in YYYY-MM-DD format"}
82
+ }
83
+ },
84
+ {
85
+ "name": "get_stock_trades",
86
+ "description": "Retrieves historical trade data for a stock with individual trade details",
87
+ "parameters": {
88
+ "symbol": {"type": "string", "required": true, "description": "Stock ticker symbol"},
89
+ "days": {"type": "integer", "required": false, "description": "Number of days of history (default: 5)"},
90
+ "limit": {"type": "integer", "required": false, "description": "Maximum number of trades to return"},
91
+ "sort": {"type": "string", "required": false, "description": "Sort order: ASC or DESC (default: ASC)"},
92
+ "feed": {"type": "string", "required": false, "description": "Data feed type"},
93
+ "currency": {"type": "string", "required": false, "description": "Currency for the data"},
94
+ "asof": {"type": "string", "required": false, "description": "As-of date in YYYY-MM-DD format"}
95
+ }
96
+ },
97
+ {
98
+ "name": "get_stock_latest_trade",
99
+ "description": "Retrieves the latest trade information for a stock",
100
+ "parameters": {
101
+ "symbol": {"type": "string", "required": true, "description": "Stock ticker symbol"},
102
+ "feed": {"type": "string", "required": false, "description": "Data feed type"},
103
+ "currency": {"type": "string", "required": false, "description": "Currency for the data"}
104
+ }
105
+ },
106
+ {
107
+ "name": "get_stock_latest_bar",
108
+ "description": "Retrieves the most recent minute bar for a stock",
109
+ "parameters": {
110
+ "symbol": {"type": "string", "required": true, "description": "Stock ticker symbol"},
111
+ "feed": {"type": "string", "required": false, "description": "Data feed type"},
112
+ "currency": {"type": "string", "required": false, "description": "Currency for the data"}
113
+ }
114
+ },
115
+ {
116
+ "name": "get_stock_snapshot",
117
+ "description": "Retrieves comprehensive snapshot with latest quote, trade, minute bar, daily bar, and previous daily bar",
118
+ "parameters": {
119
+ "symbol_or_symbols": {"type": "string|array", "required": true, "description": "Single symbol or list of symbols"},
120
+ "feed": {"type": "string", "required": false, "description": "Data feed type"},
121
+ "currency": {"type": "string", "required": false, "description": "Currency for the data"}
122
+ }
123
+ },
124
+ {
125
+ "name": "get_crypto_bars",
126
+ "description": "Retrieves historical cryptocurrency price bars with OHLCV data",
127
+ "parameters": {
128
+ "symbol": {"type": "string|array", "required": true, "description": "Crypto symbol(s) (e.g., BTC/USD, ETH/USD)"},
129
+ "days": {"type": "integer", "required": false, "description": "Number of days of history (default: 1)"},
130
+ "timeframe": {"type": "string", "required": false, "description": "Bar timeframe (default: 1Day)"},
131
+ "limit": {"type": "integer", "required": false, "description": "Maximum number of bars"},
132
+ "start": {"type": "string", "required": false, "description": "Start date"},
133
+ "end": {"type": "string", "required": false, "description": "End date"},
134
+ "feed": {"type": "string", "required": false, "description": "Crypto data feed"},
135
+ "currency": {"type": "string", "required": false, "description": "Currency for the data"}
136
+ }
137
+ },
138
+ {
139
+ "name": "get_crypto_quotes",
140
+ "description": "Retrieves historical cryptocurrency quote data with bid/ask information",
141
+ "parameters": {
142
+ "symbol": {"type": "string|array", "required": true, "description": "Crypto symbol(s)"},
143
+ "days": {"type": "integer", "required": false, "description": "Number of days of history (default: 3)"},
144
+ "limit": {"type": "integer", "required": false, "description": "Maximum number of quotes"},
145
+ "start": {"type": "string", "required": false, "description": "Start date"},
146
+ "end": {"type": "string", "required": false, "description": "End date"},
147
+ "feed": {"type": "string", "required": false, "description": "Crypto data feed"},
148
+ "currency": {"type": "string", "required": false, "description": "Currency for the data"}
149
+ }
150
+ },
151
+ {
152
+ "name": "get_orders",
153
+ "description": "Retrieves order history with filtering options by status, date range, and limits",
154
+ "parameters": {
155
+ "status": {"type": "string", "required": false, "description": "Filter by order status: all, open, closed, filled, etc. (default: all)"},
156
+ "limit": {"type": "integer", "required": false, "description": "Maximum number of orders to return (default: 10)"},
157
+ "after": {"type": "string", "required": false, "description": "Show orders after this date (YYYY-MM-DD)"},
158
+ "until": {"type": "string", "required": false, "description": "Show orders until this date (YYYY-MM-DD)"},
159
+ "direction": {"type": "string", "required": false, "description": "Sort direction: asc or desc"},
160
+ "nested": {"type": "boolean", "required": false, "description": "Include nested orders"}
161
+ }
162
+ },
163
+ {
164
+ "name": "place_stock_order",
165
+ "description": "Places a stock order with support for market, limit, stop, stop-limit, and trailing-stop orders",
166
+ "parameters": {
167
+ "symbol": {"type": "string", "required": true, "description": "Stock symbol (e.g., AAPL)"},
168
+ "side": {"type": "string", "required": true, "description": "Order side: buy or sell"},
169
+ "quantity": {"type": "number", "required": true, "description": "Number of shares"},
170
+ "order_type": {"type": "string", "required": false, "description": "Order type: market, limit, stop, stop_limit, trailing_stop (default: market)"},
171
+ "limit_price": {"type": "number", "required": false, "description": "Limit price for limit and stop_limit orders"},
172
+ "stop_price": {"type": "number", "required": false, "description": "Stop price for stop and stop_limit orders"},
173
+ "trail_price": {"type": "number", "required": false, "description": "Trail amount for trailing_stop orders"},
174
+ "trail_percent": {"type": "number", "required": false, "description": "Trail percentage for trailing_stop orders"},
175
+ "time_in_force": {"type": "string", "required": false, "description": "Time in force: day, gtc, ioc, fok (default: day)"},
176
+ "extended_hours": {"type": "boolean", "required": false, "description": "Allow extended hours trading (default: false)"},
177
+ "client_order_id": {"type": "string", "required": false, "description": "Custom order ID"}
178
+ }
179
+ },
180
+ {
181
+ "name": "place_crypto_order",
182
+ "description": "Places a cryptocurrency order with support for market, limit, and stop-limit orders",
183
+ "parameters": {
184
+ "symbol": {"type": "string", "required": true, "description": "Crypto symbol (e.g., BTC/USD, ETH/USD)"},
185
+ "side": {"type": "string", "required": true, "description": "Order side: buy or sell"},
186
+ "order_type": {"type": "string", "required": true, "description": "Order type: market, limit, stop_limit"},
187
+ "time_in_force": {"type": "string", "required": false, "description": "Time in force: gtc, ioc (default: gtc)"},
188
+ "qty": {"type": "number", "required": false, "description": "Quantity in base currency"},
189
+ "notional": {"type": "number", "required": false, "description": "Notional amount in quote currency"},
190
+ "limit_price": {"type": "number", "required": false, "description": "Limit price for limit and stop_limit orders"},
191
+ "stop_price": {"type": "number", "required": false, "description": "Stop price for stop_limit orders"},
192
+ "client_order_id": {"type": "string", "required": false, "description": "Custom order ID"}
193
+ }
194
+ },
195
+ {
196
+ "name": "cancel_all_orders",
197
+ "description": "Cancels all open orders and returns the status of each cancellation",
198
+ "parameters": {}
199
+ },
200
+ {
201
+ "name": "cancel_order_by_id",
202
+ "description": "Cancels a specific order by its ID",
203
+ "parameters": {
204
+ "order_id": {"type": "string", "required": true, "description": "The UUID of the order to cancel"}
205
+ }
206
+ },
207
+ {
208
+ "name": "close_position",
209
+ "description": "Closes a specific position for a single symbol, either partially or completely",
210
+ "parameters": {
211
+ "symbol": {"type": "string", "required": true, "description": "Symbol of the position to close"},
212
+ "qty": {"type": "string", "required": false, "description": "Specific quantity to close (optional)"},
213
+ "percentage": {"type": "string", "required": false, "description": "Percentage of position to close (optional)"}
214
+ }
215
+ },
216
+ {
217
+ "name": "close_all_positions",
218
+ "description": "Closes all open positions in the portfolio",
219
+ "parameters": {
220
+ "cancel_orders": {"type": "boolean", "required": false, "description": "Whether to cancel all open orders before liquidating positions (default: false)"}
221
+ }
222
+ },
223
+ {
224
+ "name": "exercise_options_position",
225
+ "description": "Exercises a held option contract, converting it into the underlying asset",
226
+ "parameters": {
227
+ "symbol_or_contract_id": {"type": "string", "required": true, "description": "Option contract symbol (e.g., 'NVDA250919C001680') or contract ID"}
228
+ }
229
+ },
230
+ {
231
+ "name": "get_asset_info",
232
+ "description": "Retrieves detailed information about a specific asset including trading status and attributes",
233
+ "parameters": {
234
+ "symbol": {"type": "string", "required": true, "description": "The symbol of the asset to get information for"}
235
+ }
236
+ },
237
+ {
238
+ "name": "get_all_assets",
239
+ "description": "Retrieves all available assets with optional filtering by status, class, and exchange",
240
+ "parameters": {
241
+ "status": {"type": "string", "required": false, "description": "Filter by asset status (e.g., active, inactive)"},
242
+ "asset_class": {"type": "string", "required": false, "description": "Filter by asset class (e.g., us_equity, crypto)"},
243
+ "exchange": {"type": "string", "required": false, "description": "Filter by exchange"},
244
+ "attributes": {"type": "string", "required": false, "description": "Filter by asset attributes"}
245
+ }
246
+ },
247
+ {
248
+ "name": "create_watchlist",
249
+ "description": "Creates a new watchlist with specified symbols for tracking assets",
250
+ "parameters": {
251
+ "name": {"type": "string", "required": true, "description": "Name of the watchlist"},
252
+ "symbols": {"type": "array", "required": true, "description": "List of symbols to add to the watchlist"}
253
+ }
254
+ },
255
+ {
256
+ "name": "get_watchlists",
257
+ "description": "Retrieves all watchlists for the account with their symbols",
258
+ "parameters": {}
259
+ },
260
+ {
261
+ "name": "update_watchlist",
262
+ "description": "Updates an existing watchlist by modifying name or symbols",
263
+ "parameters": {
264
+ "watchlist_id": {"type": "string", "required": true, "description": "ID of the watchlist to update"},
265
+ "name": {"type": "string", "required": false, "description": "New name for the watchlist"},
266
+ "symbols": {"type": "array", "required": false, "description": "New list of symbols for the watchlist"}
267
+ }
268
+ },
269
+ {
270
+ "name": "get_market_clock",
271
+ "description": "Retrieves current market status and next open/close times",
272
+ "parameters": {}
273
+ },
274
+ {
275
+ "name": "get_market_calendar",
276
+ "description": "Retrieves market calendar for specified date range showing trading days and holidays",
277
+ "parameters": {
278
+ "start_date": {"type": "string", "required": true, "description": "Start date in YYYY-MM-DD format"},
279
+ "end_date": {"type": "string", "required": true, "description": "End date in YYYY-MM-DD format"}
280
+ }
281
+ },
282
+ {
283
+ "name": "get_corporate_announcements",
284
+ "description": "Retrieves corporate action announcements like earnings, dividends, and stock splits",
285
+ "parameters": {
286
+ "ca_types": {"type": "array", "required": false, "description": "Types of corporate actions to filter by"},
287
+ "start": {"type": "string", "required": false, "description": "Start date for announcements"},
288
+ "end": {"type": "string", "required": false, "description": "End date for announcements"},
289
+ "symbols": {"type": "array", "required": false, "description": "List of symbols to filter by"},
290
+ "since": {"type": "string", "required": false, "description": "Return announcements since this ID"},
291
+ "until": {"type": "string", "required": false, "description": "Return announcements until this ID"}
292
+ }
293
+ },
294
+ {
295
+ "name": "get_option_contracts",
296
+ "description": "Searches for option contracts with flexible filtering by expiration, strike price, and type",
297
+ "parameters": {
298
+ "underlying_symbol": {"type": "string", "required": true, "description": "Underlying stock symbol (e.g., AAPL)"},
299
+ "expiration_date": {"type": "string", "required": false, "description": "Specific expiration date (YYYY-MM-DD)"},
300
+ "expiration_date_gte": {"type": "string", "required": false, "description": "Expiration date greater than or equal to"},
301
+ "expiration_date_lte": {"type": "string", "required": false, "description": "Expiration date less than or equal to"},
302
+ "expiration_expression": {"type": "string", "required": false, "description": "Expiration expression for complex filtering"},
303
+ "strike_price_gte": {"type": "number", "required": false, "description": "Minimum strike price"},
304
+ "strike_price_lte": {"type": "number", "required": false, "description": "Maximum strike price"},
305
+ "type": {"type": "string", "required": false, "description": "Option type: call or put"},
306
+ "status": {"type": "string", "required": false, "description": "Contract status filter"},
307
+ "root_symbol": {"type": "string", "required": false, "description": "Root symbol for the option"},
308
+ "limit": {"type": "integer", "required": false, "description": "Maximum number of contracts to return"}
309
+ }
310
+ },
311
+ {
312
+ "name": "get_option_latest_quote",
313
+ "description": "Retrieves the latest quote for an option contract with bid/ask prices and Greeks",
314
+ "parameters": {
315
+ "symbol": {"type": "string", "required": true, "description": "Option contract symbol (e.g., AAPL240315C00150000)"},
316
+ "feed": {"type": "string", "required": false, "description": "Options data feed type"}
317
+ }
318
+ },
319
+ {
320
+ "name": "get_option_snapshot",
321
+ "description": "Retrieves comprehensive snapshots of option contracts including latest trade, quote, implied volatility, and Greeks",
322
+ "parameters": {
323
+ "symbol_or_symbols": {"type": "string|array", "required": true, "description": "Single option symbol or list of option symbols"},
324
+ "feed": {"type": "string", "required": false, "description": "Options data feed type"}
325
+ }
326
+ },
327
+ {
328
+ "name": "place_option_market_order",
329
+ "description": "Places option orders including single-leg and multi-leg strategies like spreads and straddles",
330
+ "parameters": {
331
+ "legs": {"type": "array", "required": true, "description": "List of option legs with symbol, side, and quantity"},
332
+ "order_class": {"type": "string", "required": false, "description": "Order class: simple, bracket, oco, or mleg"},
333
+ "quantity": {"type": "integer", "required": false, "description": "Number of contracts (default: 1)"},
334
+ "time_in_force": {"type": "string", "required": false, "description": "Time in force: day, gtc, ioc, fok (default: day)"},
335
+ "extended_hours": {"type": "boolean", "required": false, "description": "Allow extended hours trading (default: false)"}
336
+ }
337
+ }
338
+ ],
339
+
340
+ "capabilities": {
341
+ "real_time_data": true,
342
+ "historical_data": true,
343
+ "order_management": true,
344
+ "portfolio_management": true,
345
+ "options_trading": true,
346
+ "crypto_trading": true,
347
+ "market_data": true,
348
+ "paper_trading": true,
349
+ "live_trading": true,
350
+ "watchlist_management": true,
351
+ "corporate_actions": true,
352
+ "market_calendar": true
353
+ },
354
+
355
+ "requirements": {
356
+ "python": ">=3.10",
357
+ "alpaca_account": "Required - Free paper trading or paid live account"
358
+ }
359
+ }
@@ -0,0 +1,48 @@
1
+ # Dockerfile
2
+ #
3
+ # Docker configuration for Alpaca MCP Server
4
+ # Location: /Dockerfile
5
+ # Purpose: Creates containerized deployment of the Alpaca MCP Server for Docker registry
6
+
7
+ FROM python:3.11-slim
8
+
9
+ # Set working directory
10
+ WORKDIR /app
11
+
12
+ # Install system dependencies for potential native extensions
13
+ RUN apt-get update && apt-get install -y \
14
+ gcc \
15
+ && rm -rf /var/lib/apt/lists/* \
16
+ && apt-get clean
17
+
18
+ # Copy project files
19
+ COPY pyproject.toml requirements.txt README.md ./
20
+ COPY src/ ./src/
21
+ COPY .github/core .github/core
22
+
23
+ # Install Python dependencies
24
+ # Use pip instead of uvx for container environment
25
+ RUN pip install --no-cache-dir --upgrade pip && \
26
+ pip install --no-cache-dir .
27
+
28
+ # Create non-root user for security
29
+ RUN useradd --create-home --shell /bin/bash alpaca && \
30
+ chown -R alpaca:alpaca /app
31
+ USER alpaca
32
+
33
+ # Set environment variables
34
+ ENV PYTHONPATH=/app
35
+ ENV ALPACA_PAPER_TRADE=True
36
+ ENV PYTHONUNBUFFERED=1
37
+
38
+ # Health check to verify the server can import properly
39
+ HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
40
+ CMD python -c "from alpaca_mcp_server import server; print('Health check passed')" || exit 1
41
+
42
+ # Expose port for HTTP transport (optional)
43
+ EXPOSE 8000
44
+
45
+ # Default command runs the server with stdio transport
46
+ # Can be overridden for HTTP transport: docker run -p 8000:8000 image --transport http
47
+ ENTRYPOINT ["alpaca-mcp"]
48
+ CMD ["serve"]