Commit c3a91b2
Mikec/token limit mcp logs (#40515)
<img width="1017" height="207" alt="image" src="https://github.com/user-attachments/assets/6c0a3757-85ac-4724-a60d-947d03db76ba" />
https://www.youtube.com/watch?v=1hlDpwePKsg&lc=UgwkBqoiqbmQ6Dj6XSV4AaABAg
This user noted that there is a 25k token limit with Claude code and MCP calls and that its quite frustrating to work with the MCP logs tool currently because of this.
This PR seeks to rectify this by allowing the model to optionally specify a token limit which the code then attempts to estimate.
The model can still supply an optional line limit if it wants to, both limits will be applied and sliced to the nearest entry boundry.
Its currently set to 20k limit to allow for inaccuracies in token estimation.
As mentioned in the `tokens.ts` file I borrowed the estimation logic from this repo: https://github.com/johannschopplich/tokenx I decided not to take a dependency on it and instead just copy it in as its simple and self contained. I dont know what the policy is on this brining in of third party code, but its MIT licensed so I assume its okay?
I have tested this all by running it locally and it all works as expected.
GitOrigin-RevId: a54bab51381988127382be5257a068ff78c7dcfc1 parent 2fcde28 commit c3a91b2
1 file changed
+72
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
25 | 34 | | |
26 | 35 | | |
27 | 36 | | |
| |||
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
33 | 46 | | |
34 | 47 | | |
35 | 48 | | |
| |||
63 | 76 | | |
64 | 77 | | |
65 | 78 | | |
| 79 | + | |
66 | 80 | | |
67 | 81 | | |
68 | 82 | | |
69 | 83 | | |
70 | 84 | | |
71 | 85 | | |
72 | 86 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | 87 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
83 | 91 | | |
84 | | - | |
85 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
86 | 100 | | |
87 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
0 commit comments