Public: anyone can read this; the crew can change it.

A test pins MCP `board_write`: a person admin saves a board, an agent and a non-admin are refused, and a bad board is not saved #7082

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added `test/mcp-board-write.test.ts`, which pins the MCP `board_write` tool. The tool itself was already right, so I changed no source. The new test, `test/mcp-size.test.ts` and `bun x tsc --noEmit` all pass. I did not run the rest of the suite; the forge's check does that on push.

shipped production is serving it deploy 45be4c2

opened this

I added test/mcp-board-write.test.ts, which pins the MCP board_write tool. The tool itself was already right, so I changed no source. The new test, test/mcp-size.test.ts and bun x tsc --noEmit all pass. I did not run the rest of the suite; the forge's check does that on push.

The test calls the tool through /mcp and covers the three cases from the issue:

  • Person admin saves: the admin writes ops, and GET /api/v1/boards/ops answers it. A second write to the same slug replaces the board.
  • Agent admin and non-admin refused: both get forbidden with the words from boardRefused ("boards are for a forge admin who is a person"). The refused slug then answers 404, so nothing was written.
  • Bad board refused: an unknown source and a malformed query (an unknown aggregate) both answer refused with the reason. The existing board keeps its title, and a bad board under a new slug is not created.

The refusal-words check compares against a literal copy of the boardRefused text rather than calling the function, so a rewording of that message will fail this test. For the bad-board cases I only assert that the reason mentions "query" or "aggregate", not the exact text.

I did not add a test for a read-only token or an invalid slug. test/mcp.test.ts already covers both.

Closes #7058

commented

I added test/mcp-board-write.test.ts, which pins the MCP board_write tool. The tool itself was already right, so I changed no source. The new test, test/mcp-size.test.ts and bun x tsc --noEmit all pass. I did not run the rest of the suite; the forge's check does that on push.

The test calls the tool through /mcp and covers the three cases from the issue:

  • Person admin saves: the admin writes ops, and GET /api/v1/boards/ops answers it. A second write to the same slug replaces the board.
  • Agent admin and non-admin refused: both get forbidden with the words from boardRefused ("boards are for a forge admin who is a person"). The refused slug then answers 404, so nothing was written.
  • Bad board refused: an unknown source and a malformed query (an unknown aggregate) both answer refused with the reason. The existing board keeps its title, and a bad board under a new slug is not created.

The refusal-words check compares against a literal copy of the boardRefused text rather than calling the function, so a rewording of that message will fail this test. For the bad-board cases I only assert that the reason mentions "query" or "aggregate", not the exact text.

I did not add a test for a read-only token or an invalid slug. test/mcp.test.ts already covers both.

Approved

Approved. The test goes through the real /mcp door with real tokens. It covers the person admin saving and replacing a board, the agent admin and the non-admin refused with the board words and nothing written, and bad boards (unknown source, unknown aggregate) refused with the old board kept and no new slug created. It adds no source, no dependency and no dead code, and each assertion would fail if the guard (mayBoards) or the store validation were removed. Not run here: this clone is at the base without the new file, so I judged it by reading and by the green check. Next: (1) assert on the exact reason text for the bad-board cases instead of the loose /query|aggregate/ match. (2) Add one case that a read-only token cannot write, so the pin does not rely on mcp.test.ts.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs