token-runway 0.1.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.
- token_runway-0.1.0/LICENSE +21 -0
- token_runway-0.1.0/PKG-INFO +266 -0
- token_runway-0.1.0/README.md +232 -0
- token_runway-0.1.0/pyproject.toml +75 -0
- token_runway-0.1.0/setup.cfg +4 -0
- token_runway-0.1.0/tests/test_advice.py +41 -0
- token_runway-0.1.0/tests/test_cli.py +17 -0
- token_runway-0.1.0/tests/test_injector.py +31 -0
- token_runway-0.1.0/tests/test_protocol.py +35 -0
- token_runway-0.1.0/tests/test_server.py +52 -0
- token_runway-0.1.0/tests/test_sources.py +135 -0
- token_runway-0.1.0/token_runway/__init__.py +6 -0
- token_runway-0.1.0/token_runway/__main__.py +7 -0
- token_runway-0.1.0/token_runway/cli.py +179 -0
- token_runway-0.1.0/token_runway/injector/__init__.py +9 -0
- token_runway-0.1.0/token_runway/injector/config_injector.py +80 -0
- token_runway-0.1.0/token_runway/server/__init__.py +5 -0
- token_runway-0.1.0/token_runway/server/advice.py +84 -0
- token_runway-0.1.0/token_runway/server/protocol.py +38 -0
- token_runway-0.1.0/token_runway/server/server.py +255 -0
- token_runway-0.1.0/token_runway/sources/__init__.py +68 -0
- token_runway-0.1.0/token_runway/sources/base.py +70 -0
- token_runway-0.1.0/token_runway/sources/claude.py +184 -0
- token_runway-0.1.0/token_runway/sources/colab.py +98 -0
- token_runway-0.1.0/token_runway/sources/copilot.py +209 -0
- token_runway-0.1.0/token_runway/sources/gemini.py +169 -0
- token_runway-0.1.0/token_runway.egg-info/PKG-INFO +266 -0
- token_runway-0.1.0/token_runway.egg-info/SOURCES.txt +30 -0
- token_runway-0.1.0/token_runway.egg-info/dependency_links.txt +1 -0
- token_runway-0.1.0/token_runway.egg-info/entry_points.txt +3 -0
- token_runway-0.1.0/token_runway.egg-info/requires.txt +4 -0
- token_runway-0.1.0/token_runway.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cory Pleasance
|
|
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,266 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: token-runway
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Model Context Protocol (MCP) server providing real-time token runway, quota, and rate-limit awareness for AI agents.
|
|
5
|
+
Author: Cory Pleasance
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Cpleasance/token-runway
|
|
8
|
+
Project-URL: Documentation, https://github.com/Cpleasance/token-runway#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/Cpleasance/token-runway.git
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/Cpleasance/token-runway/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/Cpleasance/token-runway/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: mcp,model-context-protocol,ai-agents,rate-limits,token-budget,claude,gemini,copilot,antigravity,llm-monitoring
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
26
|
+
Classifier: Environment :: Console
|
|
27
|
+
Requires-Python: >=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
32
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# Token Runway 🛫
|
|
36
|
+
|
|
37
|
+
[](https://pypi.org/project/token-runway/)
|
|
38
|
+
[](https://www.python.org/downloads/)
|
|
39
|
+
[](https://opensource.org/licenses/MIT)
|
|
40
|
+
[](https://modelcontextprotocol.io/)
|
|
41
|
+
|
|
42
|
+
> **Real-time token runway & rate-limit awareness for AI agents.**
|
|
43
|
+
> Give LLMs the self-awareness to weigh whether their actions are justified before exhausting your quotas.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## The Problem: Quota-Blind Agents
|
|
48
|
+
|
|
49
|
+
Modern coding agents (Claude Code, Cursor, Antigravity, Windsurf) operate blind to their own resource limits. An agent will happily fan out five parallel subagents, dump 100,000 tokens of file contents into context, or run recursive test loops when you have **2% of your 5-hour quota remaining and 15 minutes until reset**.
|
|
50
|
+
|
|
51
|
+
The result? Unplanned `HTTP 429` rate-limit lockouts, stalled workflows, and burnt monthly budgets.
|
|
52
|
+
|
|
53
|
+
## The Solution: Token Runway
|
|
54
|
+
|
|
55
|
+
**Token Runway** is a pure-Python, zero-dependency [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server and CLI tool. It aggregates live consumption metrics from your local developer tools and exposes them directly to LLMs through MCP tools, resources, and self-governance prompts.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
┌────────────────────────────────────────────────────────┐
|
|
59
|
+
│ AI Coding Agent │
|
|
60
|
+
│ "Should I launch 5 subagents for this task?" │
|
|
61
|
+
└──────────────────────────┬─────────────────────────────┘
|
|
62
|
+
│ calls assess_action()
|
|
63
|
+
▼
|
|
64
|
+
┌────────────────────────────────────────────────────────┐
|
|
65
|
+
│ Token Runway MCP │
|
|
66
|
+
│ • Claude 5-hour: 96% used (Resets in 18 min) │
|
|
67
|
+
│ • Verdict: PAUSE_OR_DOWNGRADE │
|
|
68
|
+
│ • Strategy: "Use targeted ripgrep instead of loading │
|
|
69
|
+
│ full files. Window resets in 18m." │
|
|
70
|
+
└────────────────────────────────────────────────────────┘
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Supported Providers
|
|
76
|
+
|
|
77
|
+
| Provider | Harvester Source | Metrics Exposed |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| **Anthropic Claude** | `~/.claude/` credentials & OAuth API | 5-Hour Current utilization %, Weekly 7-Day %, countdowns |
|
|
80
|
+
| **Google Gemini** | Antigravity CLI (`agy`) | Flash/Pro 5-Hour %, Flash/Pro Weekly %, Argon Weekly % |
|
|
81
|
+
| **Antigravity** | Antigravity CLI (`agy`) | Claude & GPT models 5-Hour %, Weekly % |
|
|
82
|
+
| **GitHub Copilot** | GitHub CLI (`gh api /copilot_internal/user`) | Chat Monthly %, Completions %, Plan tier, reset date |
|
|
83
|
+
| **Google Colab** | Colab CLI (`colab usage`) | Compute unit balance, burn rate/hr, active runtimes |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Quick Start
|
|
88
|
+
|
|
89
|
+
### 1. Run without installing (`uvx`)
|
|
90
|
+
|
|
91
|
+
Inspect your runway right now in your terminal:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
uvx token-runway check
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Output:
|
|
98
|
+
```text
|
|
99
|
+
=== Token Runway: Live Quota Telemetry ===
|
|
100
|
+
|
|
101
|
+
Anthropic Claude
|
|
102
|
+
• Current (5-Hour) ● CRITICAL Used: 100% (Remaining: 0.0%) (Resets in 1h 18m)
|
|
103
|
+
• Weekly (7-Day) ✔ OK Used: 76% (Remaining: 24.0%) (Resets in 3h 58m)
|
|
104
|
+
|
|
105
|
+
GitHub Copilot (Plan: free_limited_copilot)
|
|
106
|
+
• Chat Monthly ✔ OK Used: 2% (Remaining: 97.6%) [195/200] (Resets in 20h 1m)
|
|
107
|
+
• Completions Monthly ✔ OK Used: 0% (Remaining: 100.0%) [2000/2000] (Resets in 20h 1m)
|
|
108
|
+
• Premium Monthly - NOT ON PLAN
|
|
109
|
+
|
|
110
|
+
Google Gemini
|
|
111
|
+
• Flash/Pro Weekly ✔ OK Used: 7% (Remaining: 93.1%) (Resets in 3d 13h)
|
|
112
|
+
• Flash/Pro 5-Hour ✔ OK Used: 3% (Remaining: 96.7%) (Resets in 4h 37m)
|
|
113
|
+
• Argon Weekly ● CRITICAL Used: 100% (Remaining: 0.0%) (Resets in 3d 11h)
|
|
114
|
+
|
|
115
|
+
Antigravity (Claude + GPT)
|
|
116
|
+
• Weekly ✔ OK Used: 50% (Remaining: 50.2%) (Resets in 6d 16h)
|
|
117
|
+
• Current (5-Hour) ✔ OK Used: 0% (Remaining: 100.0%) (Resets in 5h 0m)
|
|
118
|
+
|
|
119
|
+
Google Colab
|
|
120
|
+
• Compute Units Balance ✔ OK [499.46]
|
|
121
|
+
• Burn Rate (/hr) ✔ OK [0.0]
|
|
122
|
+
• Active Runtimes ✔ OK [0.0]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 2. Auto-Inject into your AI IDEs
|
|
126
|
+
|
|
127
|
+
Token Runway detects your installed AI editors (**Claude Desktop**, **Cursor**, **Claude Code**, **Antigravity**, **Windsurf**) and injects the server configuration in one command:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
uvx token-runway inject
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Manual IDE Configuration
|
|
136
|
+
|
|
137
|
+
If you prefer configuring your editor manually, add the following to your `mcpServers` block:
|
|
138
|
+
|
|
139
|
+
### Claude Desktop (`claude_desktop_config.json`) / Cursor (`mcp.json`)
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"mcpServers": {
|
|
144
|
+
"token-runway": {
|
|
145
|
+
"command": "uvx",
|
|
146
|
+
"args": ["token-runway"]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Or using standard `python`:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"mcpServers": {
|
|
157
|
+
"token-runway": {
|
|
158
|
+
"command": "python",
|
|
159
|
+
"args": ["-m", "token_runway"]
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## What the Agent Sees
|
|
168
|
+
|
|
169
|
+
Token Runway registers tools, resources, and prompts with the host IDE:
|
|
170
|
+
|
|
171
|
+
### 1. `assess_action` (Tool)
|
|
172
|
+
Agents call this before embarking on expensive actions:
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"name": "assess_action",
|
|
176
|
+
"arguments": {
|
|
177
|
+
"action_type": "subagent_fanout",
|
|
178
|
+
"intensity": "high"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
**Sample Response**:
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"verdict": "pause_or_downgrade",
|
|
186
|
+
"max_utilization_pct": 100,
|
|
187
|
+
"bottleneck": {
|
|
188
|
+
"provider": "Anthropic Claude",
|
|
189
|
+
"window": "Current (5-Hour)",
|
|
190
|
+
"resets_in_minutes": 78
|
|
191
|
+
},
|
|
192
|
+
"analysis": "Quota is critically constrained (100% used on Anthropic Claude Current (5-Hour)).",
|
|
193
|
+
"preservation_strategies": [
|
|
194
|
+
"Prohibit parallel subagent fan-outs; execute one step at a time.",
|
|
195
|
+
"Read narrow line ranges (under 100 lines) instead of loading full files into context.",
|
|
196
|
+
"Route subagent prompts to lightweight models (Flash/Haiku) if model selection is supported."
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### 2. `check_runway` (Tool)
|
|
202
|
+
Returns a structured JSON snapshot of all active provider limits, reset times, and plan types.
|
|
203
|
+
|
|
204
|
+
### 3. `runway://status` (Resource)
|
|
205
|
+
Real-time JSON context stream that clients can pin to the context window.
|
|
206
|
+
|
|
207
|
+
### 4. `runway_governance` (Prompt)
|
|
208
|
+
System prompt guidelines teaching the agent how to budget tokens and adapt when limits are tight.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Diagnostic Doctor
|
|
213
|
+
|
|
214
|
+
Run `doctor` to verify which local CLIs and authentication tokens are ready:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
uvx token-runway doctor
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
```text
|
|
221
|
+
=== Token Runway: Doctor ===
|
|
222
|
+
|
|
223
|
+
✔ Claude Code: Credentials found
|
|
224
|
+
✔ Antigravity CLI (`agy`): Found in PATH
|
|
225
|
+
✔ GitHub CLI (`gh`): Found in PATH
|
|
226
|
+
✔ Google Colab CLI (`colab`): Found in PATH
|
|
227
|
+
|
|
228
|
+
Checking live endpoints...
|
|
229
|
+
✔ Anthropic Claude: Connected (2 quota windows active)
|
|
230
|
+
✔ GitHub Copilot: Connected (3 quota windows active)
|
|
231
|
+
✔ Google Gemini: Connected (3 quota windows active)
|
|
232
|
+
✔ Antigravity (Claude + GPT): Connected (2 quota windows active)
|
|
233
|
+
✔ Google Colab: Connected (3 quota windows active)
|
|
234
|
+
|
|
235
|
+
Doctor check completed.
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Design Philosophy
|
|
241
|
+
|
|
242
|
+
- **Zero Runtime Dependencies**: Written entirely in pure Python standard library (`json`, `urllib`, `subprocess`, `dataclasses`). Fast startup, no wheel compilation, no broken dependency trees.
|
|
243
|
+
- **Fail-Safe & Non-Blocking**: If a CLI is missing or a service times out, Token Runway reports `available: false` with a clear explanation without crashing the MCP connection.
|
|
244
|
+
- **Privacy First**: Runs entirely on your local machine over standard input/output (`stdio`). No usage data or tokens are sent to any third-party telemetry servers.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Contributing & Development
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
git clone https://github.com/Cpleasance/token-runway.git
|
|
252
|
+
cd token-runway
|
|
253
|
+
pip install -e ".[dev]"
|
|
254
|
+
|
|
255
|
+
# Run tests
|
|
256
|
+
pytest -v
|
|
257
|
+
|
|
258
|
+
# Run linter
|
|
259
|
+
ruff check .
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT License — Copyright (c) 2026 Cory Pleasance.
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Token Runway 🛫
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/token-runway/)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://modelcontextprotocol.io/)
|
|
7
|
+
|
|
8
|
+
> **Real-time token runway & rate-limit awareness for AI agents.**
|
|
9
|
+
> Give LLMs the self-awareness to weigh whether their actions are justified before exhausting your quotas.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## The Problem: Quota-Blind Agents
|
|
14
|
+
|
|
15
|
+
Modern coding agents (Claude Code, Cursor, Antigravity, Windsurf) operate blind to their own resource limits. An agent will happily fan out five parallel subagents, dump 100,000 tokens of file contents into context, or run recursive test loops when you have **2% of your 5-hour quota remaining and 15 minutes until reset**.
|
|
16
|
+
|
|
17
|
+
The result? Unplanned `HTTP 429` rate-limit lockouts, stalled workflows, and burnt monthly budgets.
|
|
18
|
+
|
|
19
|
+
## The Solution: Token Runway
|
|
20
|
+
|
|
21
|
+
**Token Runway** is a pure-Python, zero-dependency [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server and CLI tool. It aggregates live consumption metrics from your local developer tools and exposes them directly to LLMs through MCP tools, resources, and self-governance prompts.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
┌────────────────────────────────────────────────────────┐
|
|
25
|
+
│ AI Coding Agent │
|
|
26
|
+
│ "Should I launch 5 subagents for this task?" │
|
|
27
|
+
└──────────────────────────┬─────────────────────────────┘
|
|
28
|
+
│ calls assess_action()
|
|
29
|
+
▼
|
|
30
|
+
┌────────────────────────────────────────────────────────┐
|
|
31
|
+
│ Token Runway MCP │
|
|
32
|
+
│ • Claude 5-hour: 96% used (Resets in 18 min) │
|
|
33
|
+
│ • Verdict: PAUSE_OR_DOWNGRADE │
|
|
34
|
+
│ • Strategy: "Use targeted ripgrep instead of loading │
|
|
35
|
+
│ full files. Window resets in 18m." │
|
|
36
|
+
└────────────────────────────────────────────────────────┘
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Supported Providers
|
|
42
|
+
|
|
43
|
+
| Provider | Harvester Source | Metrics Exposed |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| **Anthropic Claude** | `~/.claude/` credentials & OAuth API | 5-Hour Current utilization %, Weekly 7-Day %, countdowns |
|
|
46
|
+
| **Google Gemini** | Antigravity CLI (`agy`) | Flash/Pro 5-Hour %, Flash/Pro Weekly %, Argon Weekly % |
|
|
47
|
+
| **Antigravity** | Antigravity CLI (`agy`) | Claude & GPT models 5-Hour %, Weekly % |
|
|
48
|
+
| **GitHub Copilot** | GitHub CLI (`gh api /copilot_internal/user`) | Chat Monthly %, Completions %, Plan tier, reset date |
|
|
49
|
+
| **Google Colab** | Colab CLI (`colab usage`) | Compute unit balance, burn rate/hr, active runtimes |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
### 1. Run without installing (`uvx`)
|
|
56
|
+
|
|
57
|
+
Inspect your runway right now in your terminal:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
uvx token-runway check
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Output:
|
|
64
|
+
```text
|
|
65
|
+
=== Token Runway: Live Quota Telemetry ===
|
|
66
|
+
|
|
67
|
+
Anthropic Claude
|
|
68
|
+
• Current (5-Hour) ● CRITICAL Used: 100% (Remaining: 0.0%) (Resets in 1h 18m)
|
|
69
|
+
• Weekly (7-Day) ✔ OK Used: 76% (Remaining: 24.0%) (Resets in 3h 58m)
|
|
70
|
+
|
|
71
|
+
GitHub Copilot (Plan: free_limited_copilot)
|
|
72
|
+
• Chat Monthly ✔ OK Used: 2% (Remaining: 97.6%) [195/200] (Resets in 20h 1m)
|
|
73
|
+
• Completions Monthly ✔ OK Used: 0% (Remaining: 100.0%) [2000/2000] (Resets in 20h 1m)
|
|
74
|
+
• Premium Monthly - NOT ON PLAN
|
|
75
|
+
|
|
76
|
+
Google Gemini
|
|
77
|
+
• Flash/Pro Weekly ✔ OK Used: 7% (Remaining: 93.1%) (Resets in 3d 13h)
|
|
78
|
+
• Flash/Pro 5-Hour ✔ OK Used: 3% (Remaining: 96.7%) (Resets in 4h 37m)
|
|
79
|
+
• Argon Weekly ● CRITICAL Used: 100% (Remaining: 0.0%) (Resets in 3d 11h)
|
|
80
|
+
|
|
81
|
+
Antigravity (Claude + GPT)
|
|
82
|
+
• Weekly ✔ OK Used: 50% (Remaining: 50.2%) (Resets in 6d 16h)
|
|
83
|
+
• Current (5-Hour) ✔ OK Used: 0% (Remaining: 100.0%) (Resets in 5h 0m)
|
|
84
|
+
|
|
85
|
+
Google Colab
|
|
86
|
+
• Compute Units Balance ✔ OK [499.46]
|
|
87
|
+
• Burn Rate (/hr) ✔ OK [0.0]
|
|
88
|
+
• Active Runtimes ✔ OK [0.0]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 2. Auto-Inject into your AI IDEs
|
|
92
|
+
|
|
93
|
+
Token Runway detects your installed AI editors (**Claude Desktop**, **Cursor**, **Claude Code**, **Antigravity**, **Windsurf**) and injects the server configuration in one command:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
uvx token-runway inject
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Manual IDE Configuration
|
|
102
|
+
|
|
103
|
+
If you prefer configuring your editor manually, add the following to your `mcpServers` block:
|
|
104
|
+
|
|
105
|
+
### Claude Desktop (`claude_desktop_config.json`) / Cursor (`mcp.json`)
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"mcpServers": {
|
|
110
|
+
"token-runway": {
|
|
111
|
+
"command": "uvx",
|
|
112
|
+
"args": ["token-runway"]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Or using standard `python`:
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"mcpServers": {
|
|
123
|
+
"token-runway": {
|
|
124
|
+
"command": "python",
|
|
125
|
+
"args": ["-m", "token_runway"]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## What the Agent Sees
|
|
134
|
+
|
|
135
|
+
Token Runway registers tools, resources, and prompts with the host IDE:
|
|
136
|
+
|
|
137
|
+
### 1. `assess_action` (Tool)
|
|
138
|
+
Agents call this before embarking on expensive actions:
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"name": "assess_action",
|
|
142
|
+
"arguments": {
|
|
143
|
+
"action_type": "subagent_fanout",
|
|
144
|
+
"intensity": "high"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
**Sample Response**:
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"verdict": "pause_or_downgrade",
|
|
152
|
+
"max_utilization_pct": 100,
|
|
153
|
+
"bottleneck": {
|
|
154
|
+
"provider": "Anthropic Claude",
|
|
155
|
+
"window": "Current (5-Hour)",
|
|
156
|
+
"resets_in_minutes": 78
|
|
157
|
+
},
|
|
158
|
+
"analysis": "Quota is critically constrained (100% used on Anthropic Claude Current (5-Hour)).",
|
|
159
|
+
"preservation_strategies": [
|
|
160
|
+
"Prohibit parallel subagent fan-outs; execute one step at a time.",
|
|
161
|
+
"Read narrow line ranges (under 100 lines) instead of loading full files into context.",
|
|
162
|
+
"Route subagent prompts to lightweight models (Flash/Haiku) if model selection is supported."
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 2. `check_runway` (Tool)
|
|
168
|
+
Returns a structured JSON snapshot of all active provider limits, reset times, and plan types.
|
|
169
|
+
|
|
170
|
+
### 3. `runway://status` (Resource)
|
|
171
|
+
Real-time JSON context stream that clients can pin to the context window.
|
|
172
|
+
|
|
173
|
+
### 4. `runway_governance` (Prompt)
|
|
174
|
+
System prompt guidelines teaching the agent how to budget tokens and adapt when limits are tight.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Diagnostic Doctor
|
|
179
|
+
|
|
180
|
+
Run `doctor` to verify which local CLIs and authentication tokens are ready:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
uvx token-runway doctor
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```text
|
|
187
|
+
=== Token Runway: Doctor ===
|
|
188
|
+
|
|
189
|
+
✔ Claude Code: Credentials found
|
|
190
|
+
✔ Antigravity CLI (`agy`): Found in PATH
|
|
191
|
+
✔ GitHub CLI (`gh`): Found in PATH
|
|
192
|
+
✔ Google Colab CLI (`colab`): Found in PATH
|
|
193
|
+
|
|
194
|
+
Checking live endpoints...
|
|
195
|
+
✔ Anthropic Claude: Connected (2 quota windows active)
|
|
196
|
+
✔ GitHub Copilot: Connected (3 quota windows active)
|
|
197
|
+
✔ Google Gemini: Connected (3 quota windows active)
|
|
198
|
+
✔ Antigravity (Claude + GPT): Connected (2 quota windows active)
|
|
199
|
+
✔ Google Colab: Connected (3 quota windows active)
|
|
200
|
+
|
|
201
|
+
Doctor check completed.
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Design Philosophy
|
|
207
|
+
|
|
208
|
+
- **Zero Runtime Dependencies**: Written entirely in pure Python standard library (`json`, `urllib`, `subprocess`, `dataclasses`). Fast startup, no wheel compilation, no broken dependency trees.
|
|
209
|
+
- **Fail-Safe & Non-Blocking**: If a CLI is missing or a service times out, Token Runway reports `available: false` with a clear explanation without crashing the MCP connection.
|
|
210
|
+
- **Privacy First**: Runs entirely on your local machine over standard input/output (`stdio`). No usage data or tokens are sent to any third-party telemetry servers.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Contributing & Development
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
git clone https://github.com/Cpleasance/token-runway.git
|
|
218
|
+
cd token-runway
|
|
219
|
+
pip install -e ".[dev]"
|
|
220
|
+
|
|
221
|
+
# Run tests
|
|
222
|
+
pytest -v
|
|
223
|
+
|
|
224
|
+
# Run linter
|
|
225
|
+
ruff check .
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
MIT License — Copyright (c) 2026 Cory Pleasance.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "token-runway"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Model Context Protocol (MCP) server providing real-time token runway, quota, and rate-limit awareness for AI agents."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{ name = "Cory Pleasance" }]
|
|
11
|
+
license = "MIT"
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
dependencies = []
|
|
14
|
+
keywords = [
|
|
15
|
+
"mcp",
|
|
16
|
+
"model-context-protocol",
|
|
17
|
+
"ai-agents",
|
|
18
|
+
"rate-limits",
|
|
19
|
+
"token-budget",
|
|
20
|
+
"claude",
|
|
21
|
+
"gemini",
|
|
22
|
+
"copilot",
|
|
23
|
+
"antigravity",
|
|
24
|
+
"llm-monitoring",
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 4 - Beta",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"Operating System :: OS Independent",
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"Programming Language :: Python :: 3.8",
|
|
32
|
+
"Programming Language :: Python :: 3.9",
|
|
33
|
+
"Programming Language :: Python :: 3.10",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
"Programming Language :: Python :: 3.13",
|
|
37
|
+
"Programming Language :: Python :: 3.14",
|
|
38
|
+
"Topic :: Software Development :: Build Tools",
|
|
39
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
40
|
+
"Environment :: Console",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
dev = ["pytest>=7.0", "ruff>=0.5"]
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
token-runway = "token_runway.cli:main"
|
|
48
|
+
tokenrunway = "token_runway.cli:main"
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/Cpleasance/token-runway"
|
|
52
|
+
Documentation = "https://github.com/Cpleasance/token-runway#readme"
|
|
53
|
+
Repository = "https://github.com/Cpleasance/token-runway.git"
|
|
54
|
+
"Bug Tracker" = "https://github.com/Cpleasance/token-runway/issues"
|
|
55
|
+
Changelog = "https://github.com/Cpleasance/token-runway/blob/main/CHANGELOG.md"
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.packages.find]
|
|
58
|
+
include = ["token_runway*"]
|
|
59
|
+
exclude = ["tests*"]
|
|
60
|
+
|
|
61
|
+
[tool.pytest.ini_options]
|
|
62
|
+
minversion = "7.0"
|
|
63
|
+
testpaths = ["tests"]
|
|
64
|
+
addopts = "-ra -q"
|
|
65
|
+
filterwarnings = ["error"]
|
|
66
|
+
|
|
67
|
+
[tool.ruff]
|
|
68
|
+
target-version = "py38"
|
|
69
|
+
line-length = 120
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint]
|
|
72
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint.per-file-ignores]
|
|
75
|
+
"tests/*" = ["E501"]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from token_runway.server.advice import evaluate_action_feasibility
|
|
2
|
+
from token_runway.sources.base import ProviderReading, QuotaWindow
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_evaluate_action_healthy():
|
|
6
|
+
readings = {
|
|
7
|
+
"claude": ProviderReading(
|
|
8
|
+
provider="claude",
|
|
9
|
+
display_name="Claude",
|
|
10
|
+
windows=[QuotaWindow(name="5h", used_pct=25)],
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
advice = evaluate_action_feasibility(readings, action_type="subagent_fanout", intensity="high")
|
|
14
|
+
assert advice["verdict"] == "proceed"
|
|
15
|
+
assert advice["max_utilization_pct"] == 25
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_evaluate_action_warning():
|
|
19
|
+
readings = {
|
|
20
|
+
"claude": ProviderReading(
|
|
21
|
+
provider="claude",
|
|
22
|
+
display_name="Claude",
|
|
23
|
+
windows=[QuotaWindow(name="5h", used_pct=85)],
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
advice = evaluate_action_feasibility(readings, action_type="subagent_fanout", intensity="high")
|
|
27
|
+
assert advice["verdict"] == "downgrade_strategy"
|
|
28
|
+
assert len(advice["preservation_strategies"]) > 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_evaluate_action_critical():
|
|
32
|
+
readings = {
|
|
33
|
+
"claude": ProviderReading(
|
|
34
|
+
provider="claude",
|
|
35
|
+
display_name="Claude",
|
|
36
|
+
windows=[QuotaWindow(name="5h", used_pct=98, resets_in_minutes=15)],
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
advice = evaluate_action_feasibility(readings, action_type="general", intensity="low")
|
|
40
|
+
assert advice["verdict"] == "pause_or_downgrade"
|
|
41
|
+
assert any("resets in ~15 minutes" in s for s in advice["preservation_strategies"])
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from token_runway.cli import main
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_cli_version(capsys):
|
|
5
|
+
try:
|
|
6
|
+
main(["--version"])
|
|
7
|
+
except SystemExit as e:
|
|
8
|
+
assert e.code == 0
|
|
9
|
+
captured = capsys.readouterr()
|
|
10
|
+
assert "token-runway 0.1.0" in captured.out
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_cli_doctor(capsys):
|
|
14
|
+
ret = main(["doctor"])
|
|
15
|
+
assert ret == 0
|
|
16
|
+
captured = capsys.readouterr()
|
|
17
|
+
assert "Token Runway: Doctor" in captured.out
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from token_runway.injector.config_injector import (
|
|
3
|
+
build_mcp_entry,
|
|
4
|
+
get_ide_config_targets,
|
|
5
|
+
inject_into_file,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_build_mcp_entry():
|
|
10
|
+
entry_uvx = build_mcp_entry("uvx")
|
|
11
|
+
assert entry_uvx["command"] == "uvx"
|
|
12
|
+
assert entry_uvx["args"] == ["token-runway"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_inject_into_file(tmp_path):
|
|
16
|
+
target = tmp_path / "claude_desktop_config.json"
|
|
17
|
+
|
|
18
|
+
# 1. Inject into fresh file
|
|
19
|
+
assert inject_into_file(target, entry_name="token-runway", mode="uvx")
|
|
20
|
+
data = json.loads(target.read_text(encoding="utf-8"))
|
|
21
|
+
assert "token-runway" in data["mcpServers"]
|
|
22
|
+
assert data["mcpServers"]["token-runway"]["command"] == "uvx"
|
|
23
|
+
|
|
24
|
+
# 2. Existing config preservation
|
|
25
|
+
data["mcpServers"]["custom-server"] = {"command": "custom"}
|
|
26
|
+
target.write_text(json.dumps(data), encoding="utf-8")
|
|
27
|
+
|
|
28
|
+
assert inject_into_file(target, entry_name="token-runway", mode="uvx")
|
|
29
|
+
updated = json.loads(target.read_text(encoding="utf-8"))
|
|
30
|
+
assert "token-runway" in updated["mcpServers"]
|
|
31
|
+
assert "custom-server" in updated["mcpServers"]
|