Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mcpcat",
"version": "0.1.6",
"version": "0.1.7",
"description": "Analytics tool for MCP (Model Context Protocol) servers - tracks tool usage patterns and provides insights",
"type": "module",
"main": "dist/index.js",
Expand All @@ -10,7 +10,7 @@
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"require": "./dist/index.cjs"
}
},
"scripts": {
Expand Down
3 changes: 1 addition & 2 deletions src/modules/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// MCPCat Settings
export const INACTIVITY_TIMEOUT_IN_MINUTES = 30;
export const DEFAULT_CONTEXT_PARAMETER_DESCRIPTION =
"Describe why you are calling this tool and how it fits into your overall task";
export const DEFAULT_CONTEXT_PARAMETER_DESCRIPTION = `Explain why you are calling this tool and how it fits into the user's overall goal. This parameter is used for analytics and user intent tracking. YOU MUST provide 15-25 words (count carefully). NEVER use first person ('I', 'we', 'you') - maintain third-person perspective. NEVER include sensitive information such as credentials, passwords, or personal data. Example (20 words): "Searching across the organization's repositories to find all open issues related to performance complaints and latency issues for team prioritization."`;
27 changes: 19 additions & 8 deletions src/tests/context-parameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ describe("Context Parameters", () => {
});

// Call list_todos without context - should fail
await expect(
client.request(
// Note: SDK <1.21.0 throws exceptions, SDK >=1.21.0 returns error responses
try {
const result1 = await client.request(
{
method: "tools/call",
params: {
Expand All @@ -263,12 +264,17 @@ describe("Context Parameters", () => {
},
},
CallToolResultSchema,
),
).rejects.toThrow();
);
// SDK 1.21.0+ behavior: returns error response
expect(result1.isError).toBe(true);
} catch (error) {
// SDK <1.21.0 behavior: throws exception
expect(error).toBeDefined();
}

// Call with empty context - should also fail
await expect(
client.request(
try {
const result2 = await client.request(
{
method: "tools/call",
params: {
Expand All @@ -277,8 +283,13 @@ describe("Context Parameters", () => {
},
},
CallToolResultSchema,
),
).rejects.toThrow();
);
// SDK 1.21.0+ behavior: returns error response
expect(result2.isError).toBe(true);
} catch (error) {
// SDK <1.21.0 behavior: throws exception
expect(error).toBeDefined();
}

// Call with valid context - should succeed
const result = await client.request(
Expand Down
5 changes: 3 additions & 2 deletions src/tests/context-preservation.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect } from "vitest";
import { addContextParameterToTool } from "../modules/context-parameters";
import { RegisteredTool } from "../types";
import { DEFAULT_CONTEXT_PARAMETER_DESCRIPTION } from "../modules/constants";

describe("Context Parameter Preservation", () => {
it("should preserve existing context parameter with custom description", () => {
Expand Down Expand Up @@ -29,7 +30,7 @@ describe("Context Parameter Preservation", () => {

// It should NOT be replaced with the default description
expect(result.inputSchema.properties.context.description).not.toBe(
"Describe why you are calling this tool and how it fits into your overall task",
DEFAULT_CONTEXT_PARAMETER_DESCRIPTION,
);
});

Expand All @@ -51,7 +52,7 @@ describe("Context Parameter Preservation", () => {
// Context should be added with default description
expect(result.inputSchema.properties.context).toBeDefined();
expect(result.inputSchema.properties.context.description).toBe(
"Describe why you are calling this tool and how it fits into your overall task",
DEFAULT_CONTEXT_PARAMETER_DESCRIPTION,
);
});
});
4 changes: 2 additions & 2 deletions src/tests/report-missing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EventCapture } from "./test-utils";
import { PublishEventRequestEventTypeEnum } from "mcpcat-api";
import { getServerTrackingData } from "../modules/internal";
import { randomUUID } from "node:crypto";
import { DEFAULT_CONTEXT_PARAMETER_DESCRIPTION } from "../modules/constants";

describe("Report Missing Tool", () => {
let server: any;
Expand Down Expand Up @@ -118,8 +119,7 @@ describe("Report Missing Tool", () => {
);
expect(addTodoTool.inputSchema.properties.context).toEqual({
type: "string",
description:
"Describe why you are calling this tool and how it fits into your overall task",
description: DEFAULT_CONTEXT_PARAMETER_DESCRIPTION,
});
expect(addTodoTool.inputSchema.required).toContain("context");
});
Expand Down