MCPcopy Create free account
hub / github.com/agent-tower/core / registerWorkspaceTools

Function registerWorkspaceTools

packages/server/src/mcp/tools/workspaces.ts:57–222  ·  view source on GitHub ↗
(
  server: McpServer,
  client: AgentTowerClient,
  context: McpContext | null = null,
  auth?: WorkspaceToolAuth
)

Source from the content-addressed store, hash-verified

55}
56
57export function registerWorkspaceTools(
58 server: McpServer,
59 client: AgentTowerClient,
60 context: McpContext | null = null,
61 auth?: WorkspaceToolAuth
62) {
63 server.tool(
64 'start_workspace_session',
65 'Create a workspace and start an AI agent session for a task.',
66 StartWorkspaceSessionInput.shape,
67 async (params) => {
68 try {
69 // 1. 创建工作空间
70 const workspace = await client.createWorkspace(params.task_id, {
71 workspaceKind: params.mode === 'main_directory' ? 'MAIN_DIRECTORY' : 'WORKTREE',
72 });
73 // 2. 创建会话
74 const session = await client.createSession(
75 workspace.id,
76 params.prompt,
77 params.provider_id
78 );
79 // 3. 启动会话
80 const started = await client.startSession(session.id);
81 return {
82 content: [{
83 type: 'text',
84 text: JSON.stringify({
85 task_id: params.task_id,
86 workspace_id: workspace.id,
87 session_id: session.id,
88 ...(started && 'operationId' in started ? { delivery: started } : {}),
89 mode: params.mode ?? 'worktree',
90 }, null, 2),
91 }],
92 };
93 } catch (e: any) {
94 return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
95 }
96 }
97 );
98
99 server.tool(
100 'get_workspace_diff',
101 'Get the code diff for a workspace.',
102 GetWorkspaceDiffInput.shape,
103 async (params) => {
104 try {
105 const result = await client.getWorkspaceDiff(params.workspace_id);
106 return { content: [{ type: 'text', text: result.diff || '(no changes)' }] };
107 } catch (e: any) {
108 return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
109 }
110 }
111 );
112
113 server.tool(
114 'merge_workspace',

Callers 2

createMcpServerFunction · 0.85
workspaces.test.tsFile · 0.85

Calls 12

requireBoundTeamRunIdFunction · 0.85
createWorkspaceMethod · 0.80
createSessionMethod · 0.80
startSessionMethod · 0.80
getWorkspaceDiffMethod · 0.80
resolveBoundTeamRunIdMethod · 0.80
mergeWorkspaceMethod · 0.80

Tested by

no test coverage detected