agent-orchestrator-mcp-server 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-orchestrator-mcp-server",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Local implementation of agent-orchestrator MCP server",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -26,11 +26,15 @@ export interface AgentRootValidationResult {
26
26
  * Validate a start_session request against the allowed agent roots constraints.
27
27
  *
28
28
  * When ALLOWED_AGENT_ROOTS is set:
29
- * - git_root must match one of the allowed agent roots
29
+ * - git_root (and optionally branch/subdirectory) must match one of the allowed agent roots
30
30
  * - mcp_servers must exactly match the default_mcp_servers of that agent root
31
31
  * (no more, no less — any deviation is rejected)
32
32
  *
33
+ * When multiple allowed agent roots share the same git_root, branch and subdirectory
34
+ * are used to disambiguate. This is critical for monorepo setups where multiple agent
35
+ * roots point to the same repository but different subdirectories.
36
+ *
33
37
  * Returns { valid: true } if the request is allowed, or { valid: false, error: string } if not.
34
38
  */
35
- export declare function validateAgentRootConstraints(allowedRoots: string[] | null, agentRoots: AgentRootInfo[], gitRoot?: string, mcpServers?: string[]): AgentRootValidationResult;
39
+ export declare function validateAgentRootConstraints(allowedRoots: string[] | null, agentRoots: AgentRootInfo[], gitRoot?: string, mcpServers?: string[], branch?: string, subdirectory?: string): AgentRootValidationResult;
36
40
  //# sourceMappingURL=allowed-agent-roots.d.ts.map
@@ -39,18 +39,34 @@ export function filterAgentRoots(agentRoots, allowedRoots) {
39
39
  * Validate a start_session request against the allowed agent roots constraints.
40
40
  *
41
41
  * When ALLOWED_AGENT_ROOTS is set:
42
- * - git_root must match one of the allowed agent roots
42
+ * - git_root (and optionally branch/subdirectory) must match one of the allowed agent roots
43
43
  * - mcp_servers must exactly match the default_mcp_servers of that agent root
44
44
  * (no more, no less — any deviation is rejected)
45
45
  *
46
+ * When multiple allowed agent roots share the same git_root, branch and subdirectory
47
+ * are used to disambiguate. This is critical for monorepo setups where multiple agent
48
+ * roots point to the same repository but different subdirectories.
49
+ *
46
50
  * Returns { valid: true } if the request is allowed, or { valid: false, error: string } if not.
47
51
  */
48
- export function validateAgentRootConstraints(allowedRoots, agentRoots, gitRoot, mcpServers) {
52
+ export function validateAgentRootConstraints(allowedRoots, agentRoots, gitRoot, mcpServers, branch, subdirectory) {
49
53
  if (allowedRoots === null) {
50
54
  return { valid: true };
51
55
  }
52
- // Find the matching agent root by git_root
53
- const matchingRoot = agentRoots.find((root) => allowedRoots.includes(root.name) && root.git_root === gitRoot);
56
+ // Find all allowed agent roots that match by git_root
57
+ const candidates = agentRoots.filter((root) => allowedRoots.includes(root.name) && root.git_root === gitRoot);
58
+ // When multiple candidates share the same git_root, disambiguate using branch and subdirectory
59
+ let matchingRoot;
60
+ if (candidates.length > 1) {
61
+ matchingRoot = candidates.find((root) => {
62
+ const branchMatch = !branch || (root.default_branch ?? 'main') === branch;
63
+ const subdirMatch = !subdirectory || root.default_subdirectory === subdirectory;
64
+ return branchMatch && subdirMatch;
65
+ });
66
+ }
67
+ else {
68
+ matchingRoot = candidates[0];
69
+ }
54
70
  if (!matchingRoot) {
55
71
  const allowedNames = allowedRoots.join(', ');
56
72
  const allowedGitRoots = agentRoots
@@ -129,7 +129,7 @@ export function startSessionTool(_server, clientFactory) {
129
129
  configs = await client.getConfigs();
130
130
  setConfigsCache(configs);
131
131
  }
132
- const validation = validateAgentRootConstraints(allowedRoots, configs.agent_roots, validatedArgs.git_root, validatedArgs.mcp_servers);
132
+ const validation = validateAgentRootConstraints(allowedRoots, configs.agent_roots, validatedArgs.git_root, validatedArgs.mcp_servers, validatedArgs.branch, validatedArgs.subdirectory);
133
133
  if (!validation.valid) {
134
134
  return {
135
135
  content: [{ type: 'text', text: `Error starting session: ${validation.error}` }],