Skip to content

Commit a23d6c3

Browse files
committed
instrumentation ++
1 parent 58c50ac commit a23d6c3

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/tools/bstack-sdk.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { BrowserStackConfig } from "../lib/types.js";
33
import { RunTestsOnBrowserStackParamsShape } from "./sdk-utils/common/schema.js";
44
import { runTestsOnBrowserStackHandler } from "./sdk-utils/handler.js";
55
import { RUN_ON_BROWSERSTACK_DESCRIPTION } from "./sdk-utils/common/constants.js";
6+
import { handleMCPError } from "../lib/utils.js";
7+
import { trackMCP } from "../lib/instrumentation.js";
68

79
export function registerRunBrowserStackTestsTool(
810
server: McpServer,
@@ -15,7 +17,12 @@ export function registerRunBrowserStackTestsTool(
1517
RUN_ON_BROWSERSTACK_DESCRIPTION,
1618
RunTestsOnBrowserStackParamsShape,
1719
async (args) => {
18-
return runTestsOnBrowserStackHandler(args, config);
20+
try {
21+
trackMCP("runTestsOnBrowserStack", server.server.getClientVersion()!, config);
22+
return await runTestsOnBrowserStackHandler(args, config);
23+
} catch (error) {
24+
return handleMCPError("runTestsOnBrowserStack", server, config, error);
25+
}
1926
},
2027
);
2128

src/tools/build-insights.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
44
import logger from "../logger.js";
55
import { BrowserStackConfig } from "../lib/types.js";
66
import { fetchFromBrowserStackAPI, handleMCPError } from "../lib/utils.js";
7+
import { trackMCP } from "../lib/instrumentation.js";
78

89
// Tool function that fetches build insights from two APIs
910
export async function fetchBuildInsightsTool(
@@ -78,6 +79,7 @@ export default function addBuildInsightsTools(
7879
},
7980
async (args) => {
8081
try {
82+
trackMCP("fetchBuildInsights", server.server.getClientVersion()!, config);
8183
return await fetchBuildInsightsTool(args, config);
8284
} catch (error) {
8385
return handleMCPError("fetchBuildInsights", server, config, error);

src/tools/rca-agent.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getRCAData } from "./rca-agent-utils/rca-data.js";
99
import { formatRCAData } from "./rca-agent-utils/format-rca.js";
1010
import { TestStatus } from "./rca-agent-utils/types.js";
1111
import { handleMCPError } from "../lib/utils.js";
12+
import { trackMCP } from "../index.js";
1213
import {
1314
FETCH_RCA_PARAMS,
1415
GET_BUILD_ID_PARAMS,
@@ -134,6 +135,7 @@ export default function addRCATools(
134135
FETCH_RCA_PARAMS,
135136
async (args) => {
136137
try {
138+
trackMCP("fetchRCA", server.server.getClientVersion()!, config);
137139
return await fetchRCADataTool(args, config);
138140
} catch (error) {
139141
return handleMCPError("fetchRCA", server, config, error);
@@ -147,6 +149,7 @@ export default function addRCATools(
147149
GET_BUILD_ID_PARAMS,
148150
async (args) => {
149151
try {
152+
trackMCP("getBuildId", server.server.getClientVersion()!, config);
150153
return await getBuildIdTool(args, config);
151154
} catch (error) {
152155
return handleMCPError("getBuildId", server, config, error);
@@ -160,6 +163,7 @@ export default function addRCATools(
160163
LIST_TEST_IDS_PARAMS,
161164
async (args) => {
162165
try {
166+
trackMCP("listTestIds", server.server.getClientVersion()!, config);
163167
return await listTestIdsTool(args, config);
164168
} catch (error) {
165169
return handleMCPError("listTestIds", server, config, error);

0 commit comments

Comments
 (0)