Repository navigation
fix: Compose OAuth behavior annotations with current catalog #1252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
62c4270
Fix OAuth MCP annotations to match tool behavior
sswiftdrtv 50cad80
Compose OAuth behavior annotations with current main
sidneyswift ab7cb8e
Merge current main while preserving OAuth annotation guards
sidneyswift 4e5b1ee
Merge commit '10fce9198fc4bacf184405e7792563fec90f7496' into codex/oa…
sidneyswift c7e2a2e
fix: address OAuth annotation review findings
sidneyswift File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { expect, it, vi } from "vitest"; | ||
| import { Client } from "@modelcontextprotocol/sdk/client/index.js"; | ||
| import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | ||
| import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js"; | ||
| import { registerOAuthTools } from "../registerOAuthTools"; | ||
| import { registerRecoupExtension } from "../../extension/registerRecoupExtension"; | ||
|
|
||
| it("discovers all seven limited registrations without invoking business services", async () => { | ||
| const services = { | ||
| listArtists: vi.fn(), | ||
| createArtist: vi.fn(), | ||
| updateArtist: vi.fn(), | ||
| getSocials: vi.fn(), | ||
| getChats: vi.fn(), | ||
| }; | ||
| const verify = vi.fn(); | ||
| const server = new McpServer({ name: "recoup-limited-test", version: "1" }); | ||
| registerOAuthTools(server, services, verify); | ||
| registerRecoupExtension(server); | ||
| const client = new Client({ name: "test", version: "1" }); | ||
| const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair(); | ||
| await server.connect(serverTransport); | ||
| await client.connect(clientTransport); | ||
| try { | ||
| const { tools } = await client.listTools(); | ||
| const expected: Record<string, [boolean, boolean, boolean]> = { | ||
| list_artists: [true, false, false], | ||
| create_new_artist: [false, false, false], | ||
| update_account_info: [false, true, false], | ||
| get_artist_socials: [true, false, false], | ||
| get_chats: [true, false, false], | ||
| open_recoup_workflows: [true, false, false], | ||
| open_recoup_workflows_sidebar: [true, false, false], | ||
| }; | ||
| expect(tools.map(tool => tool.name).sort()).toEqual(Object.keys(expected).sort()); | ||
| expect(tools).toHaveLength(7); | ||
| const modelVisibleTools = tools.filter(tool => tool.name !== "open_recoup_workflows_sidebar"); | ||
| expect(modelVisibleTools).toHaveLength(6); | ||
| for (const tool of modelVisibleTools) { | ||
| expect(tool._meta?.ui ?? {}).not.toHaveProperty("visibility"); | ||
| } | ||
| expect( | ||
| tools.find(tool => tool.name === "open_recoup_workflows_sidebar")?._meta?.ui, | ||
| ).toMatchObject({ visibility: ["app"] }); | ||
| for (const tool of tools) { | ||
| const [readOnlyHint, destructiveHint, openWorldHint] = expected[tool.name]; | ||
| expect(tool.annotations).toMatchObject({ readOnlyHint, destructiveHint, openWorldHint }); | ||
| expect(tool.inputSchema.properties).not.toHaveProperty("account_id"); | ||
| } | ||
| expect(verify).not.toHaveBeenCalled(); | ||
| for (const service of Object.values(services)) expect(service).not.toHaveBeenCalled(); | ||
| } finally { | ||
| await client.close(); | ||
| await server.close(); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
lib/mcp/oauth/__tests__/standardCatalogAnnotations.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { expect, it, vi } from "vitest"; | ||
| import { Client } from "@modelcontextprotocol/sdk/client/index.js"; | ||
| import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | ||
| import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js"; | ||
| import { registerCatalogCaseTools } from "@/lib/mcp/tools/context/registerCatalogCaseTools"; | ||
| import { handleContextToolOperation } from "@/lib/mcp/tools/context/handleContextToolOperation"; | ||
| import { catalogCaseToolOperations } from "../catalogCaseToolOperations"; | ||
|
|
||
| vi.mock("@/lib/mcp/tools/context/handleContextToolOperation", () => ({ | ||
| handleContextToolOperation: vi.fn(), | ||
| })); | ||
|
|
||
| it("discovers standard catalog annotations without executing handlers or granting delegation", async () => { | ||
| const server = new McpServer({ name: "catalog-annotations-test", version: "1" }); | ||
| registerCatalogCaseTools(server); | ||
| const client = new Client({ name: "test", version: "1" }); | ||
| const [ct, st] = InMemoryTransport.createLinkedPair(); | ||
| await server.connect(st); | ||
| await client.connect(ct); | ||
| try { | ||
| const { tools } = await client.listTools(); | ||
| const expected: Record<string, [boolean, boolean, boolean]> = { | ||
| prepare_catalog_audit: [true, false, false], | ||
| save_catalog_case: [false, true, false], | ||
| read_catalog_case: [true, false, false], | ||
| list_catalog_cases: [true, false, false], | ||
| }; | ||
| expect(tools.map(tool => tool.name).sort()).toEqual(Object.keys(expected).sort()); | ||
| for (const tool of tools) { | ||
| const [readOnlyHint, destructiveHint, openWorldHint] = expected[tool.name]; | ||
| expect(tool.annotations, tool.name).toMatchObject({ | ||
| readOnlyHint, | ||
| destructiveHint, | ||
| openWorldHint, | ||
| }); | ||
| expect(tool.inputSchema.properties).not.toHaveProperty("account_id"); | ||
| } | ||
| for (const operation of Object.values(catalogCaseToolOperations)) { | ||
| expect(operation.delegated).toBe(false); | ||
| } | ||
| expect(handleContextToolOperation).not.toHaveBeenCalled(); | ||
| } finally { | ||
| await client.close(); | ||
| await server.close(); | ||
| } | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: Custom agent: Enforce Clear Code Style and Maintainability Practices
This file is now 103 lines, over the 100-line cap in the code-style rules, and the new annotations test is what pushed it past the limit. Trim the added test or fixture lines so the file stays under 100 lines (at or below 99).
Prompt for AI agents