From 7f5c5b52d34d62a19e5be130f84613ec76ecdad4 Mon Sep 17 00:00:00 2001 From: Lucas Woodward <31957045+SketchingDev@users.noreply.github.com> Date: Wed, 3 Dec 2025 22:09:56 +0000 Subject: [PATCH 1/2] Return endpoint usage --- .../oauthClientUsage/oauthClientUsage.test.ts | 17 +++++++++-------- src/tools/oauthClientUsage/oauthClientUsage.ts | 15 ++++++++------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/tools/oauthClientUsage/oauthClientUsage.test.ts b/src/tools/oauthClientUsage/oauthClientUsage.test.ts index 746a966..45eb4a6 100644 --- a/src/tools/oauthClientUsage/oauthClientUsage.test.ts +++ b/src/tools/oauthClientUsage/oauthClientUsage.test.ts @@ -18,6 +18,7 @@ describe("OAuth Client Usage", () => { postOauthClientUsageQuery: vi.fn(), getOauthClientUsageQueryResult: vi.fn(), }, + cache: undefined, }; const toolDefinition = oauthClientUsage(toolDeps); toolName = toolDefinition.schema.name; @@ -141,8 +142,6 @@ describe("OAuth Client Usage", () => { test("OAuth Client usage returned for date range", async () => { const oauthClientId = randomUUID(); const executionId = randomUUID(); - const organisationOneId = randomUUID(); - const organisationTwoId = randomUUID(); toolDeps.oauthApi.postOauthClientUsageQuery.mockResolvedValue({ executionId, @@ -152,11 +151,13 @@ describe("OAuth Client Usage", () => { toolDeps.oauthApi.getOauthClientUsageQueryResult.mockResolvedValue({ results: [ { - organizationId: organisationOneId, + templateUri: "api/v2/authorization/divisions", + httpMethod: "GET", requests: 5, }, { - organizationId: organisationTwoId, + templateUri: "api/v2/authorization/roles", + httpMethod: "GET", requests: 10, }, ], @@ -181,14 +182,14 @@ describe("OAuth Client Usage", () => { text: JSON.stringify({ startDate, endDate, - totalRequest: 15, - requestsPerOrganisation: [ + totalRequests: 15, + requestsPerEndpoint: [ { - organisationId: organisationOneId, + endpoint: "GET api/v2/authorization/divisions", requests: 5, }, { - organisationId: organisationTwoId, + endpoint: "GET api/v2/authorization/roles", requests: 10, }, ], diff --git a/src/tools/oauthClientUsage/oauthClientUsage.ts b/src/tools/oauthClientUsage/oauthClientUsage.ts index 8e9ffcd..30592cc 100644 --- a/src/tools/oauthClientUsage/oauthClientUsage.ts +++ b/src/tools/oauthClientUsage/oauthClientUsage.ts @@ -12,9 +12,9 @@ const TOOL_CACHE_KEY = "oauthClientUsage"; export interface OAuthClientUsageResponse { startDate: string; endDate: string; - totalRequest: number; - requestsPerOrganisation: { - organisationId?: string; + totalRequests: number; + requestsPerEndpoint: { + endpoint?: string; requests?: number; }[]; } @@ -91,7 +91,7 @@ export const oauthClientUsage: ToolFactory< result = await oauthApi.postOauthClientUsageQuery(oauthClientId, { interval: `${from.toISOString()}/${to.toISOString()}`, metrics: ["Requests"], - groupBy: ["OrganizationId"], + groupBy: ["TemplateUri", "HttpMethod"], }); } catch (error: unknown) { const errorMessage = isUnauthorisedError(error) @@ -147,13 +147,14 @@ export const oauthClientUsage: ToolFactory< const toolResult: OAuthClientUsageResponse = { startDate, endDate, - totalRequest: (apiUsageQueryResult?.results ?? []).reduce( + totalRequests: (apiUsageQueryResult?.results ?? []).reduce( (acc, curr) => acc + (curr.requests ?? 0), 0, ), - requestsPerOrganisation: (apiUsageQueryResult?.results ?? []).map( + requestsPerEndpoint: (apiUsageQueryResult?.results ?? []).map( (result) => ({ - organisationId: result.organizationId, + endpoint: + [result.httpMethod, result.templateUri].join(" ") || undefined, requests: result.requests, }), ), From 4f5fa394fc30db358661091861a80460d4bfd4f0 Mon Sep 17 00:00:00 2001 From: Lucas Woodward <31957045+SketchingDev@users.noreply.github.com> Date: Wed, 3 Dec 2025 22:15:53 +0000 Subject: [PATCH 2/2] Update tool description and version --- README.md | 2 +- docs/tools.md | 2 +- manifest.json | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- src/index.ts | 2 +- src/tools/oauthClientUsage/oauthClientUsage.test.ts | 2 +- src/tools/oauthClientUsage/oauthClientUsage.ts | 4 ++-- tests/integration/serverRuns.test.ts | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fe935e4..7e10ed1 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ A Model Context Protocol (MCP) server for Genesys Cloud's Platform API. | [Search Voice Conversation](/docs/tools.md#search-voice-conversations) | Searches voice conversations by optional criteria | | [Conversation Transcript](/docs/tools.md#conversation-transcript) | Retrieves conversation transcript | | [OAuth Clients](/docs/tools.md#oauth-clients) | Retrieves a list of all the OAuth clients | -| [OAuth Client Usage](/docs/tools.md#oauth-client-usage) | Retrieves usage of an OAuth client | +| [OAuth Client Usage](/docs/tools.md#oauth-client-usage) | Retrieves OAuth client usage for given period | ## Usage with Claude Desktop diff --git a/docs/tools.md b/docs/tools.md index bf6513a..3e5999c 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -242,7 +242,7 @@ Platform API endpoints used: **Tool name:** `oauth_client_usage` -Retrieves the usage of an OAuth Client for a given period. It returns the total number of requests and a breakdown of requests per organization. +Retrieves the usage of an OAuth Client for a given period. It returns the total number of requests and a breakdown of Platform API endpoints used by the client. [Source file](/src/tools/oauthClientUsage/oauthClientUsage.ts). diff --git a/manifest.json b/manifest.json index 6c4c583..1d83202 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": "0.2", "name": "Genesys Cloud MCP Server", - "version": "1.0.2", + "version": "1.0.3", "description": "Interact with Genesys Cloud's Platform API", "long_description": "This extension allows Claude to connect to Genesys Cloud's Platform API via a local MCP server. It provides tools for querying queue volumes, retrieving conversation samples, analyzing sentiment and voice quality, accessing transcripts, and more.\n\nThis project is not affiliated with Genesys.", "author": { @@ -62,7 +62,7 @@ }, { "name": "oauth_client_usage", - "description": "Retrieves the usage of an OAuth Client for a given period. It returns the total number of requests and a breakdown of requests per organization." + "description": "Retrieves the usage of an OAuth Client for a given period. It returns the total number of requests and a breakdown of Platform API endpoints used by the client." } ], "user_config": { diff --git a/package-lock.json b/package-lock.json index 35148d8..cb0fe71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@makingchatbots/genesys-cloud-mcp-server", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@makingchatbots/genesys-cloud-mcp-server", - "version": "1.0.2", + "version": "1.0.3", "license": "MIT", "dependencies": { "@modelcontextprotocol/sdk": "^1.18.2", diff --git a/package.json b/package.json index f2a41cf..758e0c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@makingchatbots/genesys-cloud-mcp-server", - "version": "1.0.2", + "version": "1.0.3", "description": "A Model Context Protocol (MCP) server exposing Genesys Cloud tools for LLMs, including sentiment analysis, conversation search, topic detection and more.", "bin": "./dist/cli.js", "type": "module", diff --git a/src/index.ts b/src/index.ts index b7f4078..406634c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,7 @@ const withAuth = OAuthClientCredentialsWrapper( const server: McpServer = new McpServer({ name: "Genesys Cloud", - version: "1.0.2", // Same version as version in package.json + version: "1.0.3", // Same version as version in package.json }); const cache = new LRUCache({ diff --git a/src/tools/oauthClientUsage/oauthClientUsage.test.ts b/src/tools/oauthClientUsage/oauthClientUsage.test.ts index 45eb4a6..725ae51 100644 --- a/src/tools/oauthClientUsage/oauthClientUsage.test.ts +++ b/src/tools/oauthClientUsage/oauthClientUsage.test.ts @@ -49,7 +49,7 @@ describe("OAuth Client Usage", () => { _meta: undefined, annotations: { title: "OAuth Client Usage" }, description: - "Retrieves the usage of an OAuth Client for a given period. It returns the total number of requests and a breakdown of requests per organization.", + "Retrieves the usage of an OAuth Client for a given period. It returns the total number of requests and a breakdown of Platform API endpoints used by the client.", inputSchema: { properties: { oauthClientId: { diff --git a/src/tools/oauthClientUsage/oauthClientUsage.ts b/src/tools/oauthClientUsage/oauthClientUsage.ts index 30592cc..a4d09a7 100644 --- a/src/tools/oauthClientUsage/oauthClientUsage.ts +++ b/src/tools/oauthClientUsage/oauthClientUsage.ts @@ -7,7 +7,7 @@ import { isUnauthorisedError } from "../utils/genesys/isUnauthorisedError.js"; import { waitFor } from "../utils/waitFor.js"; const MAX_ATTEMPTS = 10; -const TOOL_CACHE_KEY = "oauthClientUsage"; +const TOOL_CACHE_KEY = "oauth-client-usage"; export interface OAuthClientUsageResponse { startDate: string; @@ -55,7 +55,7 @@ export const oauthClientUsage: ToolFactory< name: "oauth_client_usage", annotations: { title: "OAuth Client Usage" }, description: - "Retrieves the usage of an OAuth Client for a given period. It returns the total number of requests and a breakdown of requests per organization.", + "Retrieves the usage of an OAuth Client for a given period. It returns the total number of requests and a breakdown of Platform API endpoints used by the client.", paramsSchema, }, call: async ({ oauthClientId, startDate, endDate }) => { diff --git a/tests/integration/serverRuns.test.ts b/tests/integration/serverRuns.test.ts index 5c85b1d..e20816f 100644 --- a/tests/integration/serverRuns.test.ts +++ b/tests/integration/serverRuns.test.ts @@ -81,7 +81,7 @@ describe("Server Runs", () => { client = new Client({ name: "test-client", - version: "1.0.2", + version: "1.0.3", }); await client.connect(transport);