mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
Add GitHub MCP support to agent mode
- Parse --allowedTools from claude_args to detect when user wants GitHub MCPs - Wire up github_inline_comment server in prepareMcpConfig for PR contexts - Update agent mode to use prepareMcpConfig instead of manual config - Add comprehensive tests for parseAllowedTools edge cases - Fix TypeScript types to support both entity and automation contexts
This commit is contained in:
69
test/modes/parse-tools.test.ts
Normal file
69
test/modes/parse-tools.test.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { parseAllowedTools } from "../../src/modes/agent/parse-tools";
|
||||
|
||||
describe("parseAllowedTools", () => {
|
||||
test("parses unquoted tools", () => {
|
||||
const args = "--allowedTools mcp__github__*,mcp__github_comment__*";
|
||||
expect(parseAllowedTools(args)).toEqual([
|
||||
"mcp__github__*",
|
||||
"mcp__github_comment__*",
|
||||
]);
|
||||
});
|
||||
|
||||
test("parses double-quoted tools", () => {
|
||||
const args = '--allowedTools "mcp__github__*,mcp__github_comment__*"';
|
||||
expect(parseAllowedTools(args)).toEqual([
|
||||
"mcp__github__*",
|
||||
"mcp__github_comment__*",
|
||||
]);
|
||||
});
|
||||
|
||||
test("parses single-quoted tools", () => {
|
||||
const args = "--allowedTools 'mcp__github__*,mcp__github_comment__*'";
|
||||
expect(parseAllowedTools(args)).toEqual([
|
||||
"mcp__github__*",
|
||||
"mcp__github_comment__*",
|
||||
]);
|
||||
});
|
||||
|
||||
test("returns empty array when no allowedTools", () => {
|
||||
const args = "--someOtherFlag value";
|
||||
expect(parseAllowedTools(args)).toEqual([]);
|
||||
});
|
||||
|
||||
test("handles empty string", () => {
|
||||
expect(parseAllowedTools("")).toEqual([]);
|
||||
});
|
||||
|
||||
test("handles duplicate --allowedTools flags", () => {
|
||||
const args = "--allowedTools --allowedTools mcp__github__*";
|
||||
// Should not match the first one since the value is another flag
|
||||
expect(parseAllowedTools(args)).toEqual([]);
|
||||
});
|
||||
|
||||
test("handles typo --alloedTools", () => {
|
||||
const args = "--alloedTools mcp__github__*";
|
||||
expect(parseAllowedTools(args)).toEqual([]);
|
||||
});
|
||||
|
||||
test("handles multiple flags with allowedTools in middle", () => {
|
||||
const args = '--flag1 value1 --allowedTools "mcp__github__*" --flag2 value2';
|
||||
expect(parseAllowedTools(args)).toEqual(["mcp__github__*"]);
|
||||
});
|
||||
|
||||
test("trims whitespace from tool names", () => {
|
||||
const args = "--allowedTools 'mcp__github__* , mcp__github_comment__* '";
|
||||
expect(parseAllowedTools(args)).toEqual([
|
||||
"mcp__github__*",
|
||||
"mcp__github_comment__*",
|
||||
]);
|
||||
});
|
||||
|
||||
test("handles tools with special characters", () => {
|
||||
const args = '--allowedTools "mcp__github__create_issue,mcp__github_comment__update"';
|
||||
expect(parseAllowedTools(args)).toEqual([
|
||||
"mcp__github__create_issue",
|
||||
"mcp__github_comment__update",
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user