@vibescope/mcp-server 0.2.0 → 0.2.2
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.
- package/README.md +60 -7
- package/dist/api-client.d.ts +251 -1
- package/dist/api-client.js +82 -3
- package/dist/handlers/blockers.js +9 -8
- package/dist/handlers/bodies-of-work.js +96 -63
- package/dist/handlers/connectors.d.ts +45 -0
- package/dist/handlers/connectors.js +183 -0
- package/dist/handlers/cost.d.ts +10 -0
- package/dist/handlers/cost.js +112 -50
- package/dist/handlers/decisions.js +32 -19
- package/dist/handlers/deployment.js +144 -122
- package/dist/handlers/discovery.d.ts +7 -0
- package/dist/handlers/discovery.js +96 -7
- package/dist/handlers/fallback.js +29 -23
- package/dist/handlers/file-checkouts.d.ts +20 -0
- package/dist/handlers/file-checkouts.js +133 -0
- package/dist/handlers/findings.d.ts +6 -0
- package/dist/handlers/findings.js +96 -40
- package/dist/handlers/git-issues.js +40 -36
- package/dist/handlers/ideas.js +49 -31
- package/dist/handlers/index.d.ts +3 -0
- package/dist/handlers/index.js +9 -0
- package/dist/handlers/milestones.js +39 -32
- package/dist/handlers/organizations.js +99 -91
- package/dist/handlers/progress.js +24 -13
- package/dist/handlers/project.js +68 -28
- package/dist/handlers/requests.js +18 -14
- package/dist/handlers/roles.d.ts +18 -0
- package/dist/handlers/roles.js +130 -0
- package/dist/handlers/session.js +58 -17
- package/dist/handlers/sprints.js +93 -81
- package/dist/handlers/tasks.d.ts +2 -0
- package/dist/handlers/tasks.js +189 -91
- package/dist/handlers/types.d.ts +64 -2
- package/dist/handlers/types.js +48 -1
- package/dist/handlers/validation.js +21 -17
- package/dist/index.js +7 -2716
- package/dist/token-tracking.d.ts +74 -0
- package/dist/token-tracking.js +122 -0
- package/dist/tools.js +685 -9
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +17 -0
- package/docs/TOOLS.md +2053 -0
- package/package.json +4 -1
- package/scripts/generate-docs.ts +212 -0
- package/src/api-client.test.ts +718 -0
- package/src/api-client.ts +320 -6
- package/src/handlers/__test-setup__.ts +16 -0
- package/src/handlers/blockers.test.ts +31 -19
- package/src/handlers/blockers.ts +9 -8
- package/src/handlers/bodies-of-work.test.ts +55 -32
- package/src/handlers/bodies-of-work.ts +115 -115
- package/src/handlers/connectors.test.ts +834 -0
- package/src/handlers/connectors.ts +229 -0
- package/src/handlers/cost.test.ts +34 -44
- package/src/handlers/cost.ts +136 -85
- package/src/handlers/decisions.test.ts +37 -27
- package/src/handlers/decisions.ts +35 -30
- package/src/handlers/deployment.ts +180 -208
- package/src/handlers/discovery.test.ts +4 -5
- package/src/handlers/discovery.ts +98 -8
- package/src/handlers/fallback.test.ts +26 -22
- package/src/handlers/fallback.ts +36 -33
- package/src/handlers/file-checkouts.test.ts +670 -0
- package/src/handlers/file-checkouts.ts +165 -0
- package/src/handlers/findings.test.ts +178 -19
- package/src/handlers/findings.ts +112 -74
- package/src/handlers/git-issues.test.ts +51 -43
- package/src/handlers/git-issues.ts +44 -84
- package/src/handlers/ideas.test.ts +28 -23
- package/src/handlers/ideas.ts +61 -59
- package/src/handlers/index.ts +9 -0
- package/src/handlers/milestones.test.ts +33 -28
- package/src/handlers/milestones.ts +52 -50
- package/src/handlers/organizations.test.ts +104 -83
- package/src/handlers/organizations.ts +117 -142
- package/src/handlers/progress.test.ts +20 -14
- package/src/handlers/progress.ts +26 -24
- package/src/handlers/project.test.ts +34 -27
- package/src/handlers/project.ts +95 -63
- package/src/handlers/requests.test.ts +27 -18
- package/src/handlers/requests.ts +21 -17
- package/src/handlers/roles.test.ts +303 -0
- package/src/handlers/roles.ts +208 -0
- package/src/handlers/session.test.ts +47 -0
- package/src/handlers/session.ts +71 -26
- package/src/handlers/sprints.test.ts +71 -50
- package/src/handlers/sprints.ts +113 -146
- package/src/handlers/tasks.test.ts +77 -15
- package/src/handlers/tasks.ts +231 -156
- package/src/handlers/tool-categories.test.ts +66 -0
- package/src/handlers/types.ts +81 -2
- package/src/handlers/validation.test.ts +78 -45
- package/src/handlers/validation.ts +23 -25
- package/src/index.ts +12 -2732
- package/src/token-tracking.test.ts +453 -0
- package/src/token-tracking.ts +164 -0
- package/src/tools.ts +685 -9
- package/src/utils.test.ts +2 -2
- package/src/utils.ts +17 -0
- package/dist/config/tool-categories.d.ts +0 -31
- package/dist/config/tool-categories.js +0 -253
- package/dist/knowledge.d.ts +0 -6
- package/dist/knowledge.js +0 -218
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Tracking Utilities
|
|
3
|
+
*
|
|
4
|
+
* Functions for estimating and tracking token usage across MCP tool calls.
|
|
5
|
+
* Extracted from index.ts to enable unit testing.
|
|
6
|
+
*/
|
|
7
|
+
export interface ModelTokens {
|
|
8
|
+
input: number;
|
|
9
|
+
output: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TokenUsage {
|
|
12
|
+
callCount: number;
|
|
13
|
+
totalTokens: number;
|
|
14
|
+
byTool: Record<string, {
|
|
15
|
+
calls: number;
|
|
16
|
+
tokens: number;
|
|
17
|
+
}>;
|
|
18
|
+
byModel: Record<string, ModelTokens>;
|
|
19
|
+
currentModel: string | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Estimate tokens from a JSON-serializable object.
|
|
23
|
+
* Uses a rough heuristic of ~4 characters per token.
|
|
24
|
+
*
|
|
25
|
+
* @param obj - Any JSON-serializable object
|
|
26
|
+
* @returns Estimated token count (always >= 1)
|
|
27
|
+
*/
|
|
28
|
+
export declare function estimateTokens(obj: unknown): number;
|
|
29
|
+
/**
|
|
30
|
+
* Create a fresh token usage tracker.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createTokenUsage(): TokenUsage;
|
|
33
|
+
/**
|
|
34
|
+
* Track token usage for a tool call.
|
|
35
|
+
* Updates the usage object in-place with input/output token estimates.
|
|
36
|
+
*
|
|
37
|
+
* @param usage - The token usage object to update
|
|
38
|
+
* @param toolName - Name of the tool being called
|
|
39
|
+
* @param args - Input arguments to the tool
|
|
40
|
+
* @param response - Response from the tool
|
|
41
|
+
*/
|
|
42
|
+
export declare function trackTokenUsage(usage: TokenUsage, toolName: string, args: unknown, response: unknown): void;
|
|
43
|
+
/**
|
|
44
|
+
* Set the current model for token tracking.
|
|
45
|
+
* Subsequent calls to trackTokenUsage will be attributed to this model.
|
|
46
|
+
*
|
|
47
|
+
* @param usage - The token usage object to update
|
|
48
|
+
* @param model - Model name (e.g., "opus", "sonnet", "haiku")
|
|
49
|
+
*/
|
|
50
|
+
export declare function setCurrentModel(usage: TokenUsage, model: string | null): void;
|
|
51
|
+
/**
|
|
52
|
+
* Reset token usage tracking to initial state.
|
|
53
|
+
*
|
|
54
|
+
* @param usage - The token usage object to reset
|
|
55
|
+
*/
|
|
56
|
+
export declare function resetTokenUsage(usage: TokenUsage): void;
|
|
57
|
+
/**
|
|
58
|
+
* Get a summary of token usage for reporting.
|
|
59
|
+
*
|
|
60
|
+
* @param usage - The token usage object
|
|
61
|
+
* @returns Summary object with stats
|
|
62
|
+
*/
|
|
63
|
+
export declare function getTokenUsageSummary(usage: TokenUsage): {
|
|
64
|
+
total_calls: number;
|
|
65
|
+
total_tokens: number;
|
|
66
|
+
average_tokens_per_call: number;
|
|
67
|
+
by_tool: Record<string, {
|
|
68
|
+
calls: number;
|
|
69
|
+
tokens: number;
|
|
70
|
+
avg: number;
|
|
71
|
+
}>;
|
|
72
|
+
by_model: Record<string, ModelTokens>;
|
|
73
|
+
current_model: string | null;
|
|
74
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Tracking Utilities
|
|
3
|
+
*
|
|
4
|
+
* Functions for estimating and tracking token usage across MCP tool calls.
|
|
5
|
+
* Extracted from index.ts to enable unit testing.
|
|
6
|
+
*/
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Token Estimation
|
|
9
|
+
// ============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Estimate tokens from a JSON-serializable object.
|
|
12
|
+
* Uses a rough heuristic of ~4 characters per token.
|
|
13
|
+
*
|
|
14
|
+
* @param obj - Any JSON-serializable object
|
|
15
|
+
* @returns Estimated token count (always >= 1)
|
|
16
|
+
*/
|
|
17
|
+
export function estimateTokens(obj) {
|
|
18
|
+
try {
|
|
19
|
+
const json = JSON.stringify(obj);
|
|
20
|
+
return Math.max(1, Math.ceil(json.length / 4));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// If JSON serialization fails, return a minimal estimate
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Token Usage Tracking
|
|
29
|
+
// ============================================================================
|
|
30
|
+
/**
|
|
31
|
+
* Create a fresh token usage tracker.
|
|
32
|
+
*/
|
|
33
|
+
export function createTokenUsage() {
|
|
34
|
+
return {
|
|
35
|
+
callCount: 0,
|
|
36
|
+
totalTokens: 0,
|
|
37
|
+
byTool: {},
|
|
38
|
+
byModel: {},
|
|
39
|
+
currentModel: null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Track token usage for a tool call.
|
|
44
|
+
* Updates the usage object in-place with input/output token estimates.
|
|
45
|
+
*
|
|
46
|
+
* @param usage - The token usage object to update
|
|
47
|
+
* @param toolName - Name of the tool being called
|
|
48
|
+
* @param args - Input arguments to the tool
|
|
49
|
+
* @param response - Response from the tool
|
|
50
|
+
*/
|
|
51
|
+
export function trackTokenUsage(usage, toolName, args, response) {
|
|
52
|
+
const inputTokens = estimateTokens(args);
|
|
53
|
+
const outputTokens = estimateTokens(response);
|
|
54
|
+
const totalTokens = inputTokens + outputTokens;
|
|
55
|
+
usage.callCount++;
|
|
56
|
+
usage.totalTokens += totalTokens;
|
|
57
|
+
if (!usage.byTool[toolName]) {
|
|
58
|
+
usage.byTool[toolName] = { calls: 0, tokens: 0 };
|
|
59
|
+
}
|
|
60
|
+
usage.byTool[toolName].calls++;
|
|
61
|
+
usage.byTool[toolName].tokens += totalTokens;
|
|
62
|
+
// Track by model if a model is set
|
|
63
|
+
const model = usage.currentModel;
|
|
64
|
+
if (model) {
|
|
65
|
+
if (!usage.byModel[model]) {
|
|
66
|
+
usage.byModel[model] = { input: 0, output: 0 };
|
|
67
|
+
}
|
|
68
|
+
usage.byModel[model].input += inputTokens;
|
|
69
|
+
usage.byModel[model].output += outputTokens;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Set the current model for token tracking.
|
|
74
|
+
* Subsequent calls to trackTokenUsage will be attributed to this model.
|
|
75
|
+
*
|
|
76
|
+
* @param usage - The token usage object to update
|
|
77
|
+
* @param model - Model name (e.g., "opus", "sonnet", "haiku")
|
|
78
|
+
*/
|
|
79
|
+
export function setCurrentModel(usage, model) {
|
|
80
|
+
usage.currentModel = model;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Reset token usage tracking to initial state.
|
|
84
|
+
*
|
|
85
|
+
* @param usage - The token usage object to reset
|
|
86
|
+
*/
|
|
87
|
+
export function resetTokenUsage(usage) {
|
|
88
|
+
usage.callCount = 0;
|
|
89
|
+
usage.totalTokens = 0;
|
|
90
|
+
usage.byTool = {};
|
|
91
|
+
usage.byModel = {};
|
|
92
|
+
usage.currentModel = null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get a summary of token usage for reporting.
|
|
96
|
+
*
|
|
97
|
+
* @param usage - The token usage object
|
|
98
|
+
* @returns Summary object with stats
|
|
99
|
+
*/
|
|
100
|
+
export function getTokenUsageSummary(usage) {
|
|
101
|
+
const byTool = {};
|
|
102
|
+
for (const [tool, stats] of Object.entries(usage.byTool)) {
|
|
103
|
+
byTool[tool] = {
|
|
104
|
+
calls: stats.calls,
|
|
105
|
+
tokens: stats.tokens,
|
|
106
|
+
avg: stats.calls > 0 ? Math.round(stats.tokens / stats.calls) : 0,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// Deep copy byModel to prevent mutation
|
|
110
|
+
const byModel = {};
|
|
111
|
+
for (const [model, tokens] of Object.entries(usage.byModel)) {
|
|
112
|
+
byModel[model] = { input: tokens.input, output: tokens.output };
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
total_calls: usage.callCount,
|
|
116
|
+
total_tokens: usage.totalTokens,
|
|
117
|
+
average_tokens_per_call: usage.callCount > 0 ? Math.round(usage.totalTokens / usage.callCount) : 0,
|
|
118
|
+
by_tool: byTool,
|
|
119
|
+
by_model: byModel,
|
|
120
|
+
current_model: usage.currentModel,
|
|
121
|
+
};
|
|
122
|
+
}
|