mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-21 00:49:45 +01:00
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
import * as z from 'zod/v4';
|
|
import type { McpServerContext } from '../types.js';
|
|
import { getWorkspaceContext } from './helpers.js';
|
|
|
|
export function registerWindowTools(server: McpServer, ctx: McpServerContext) {
|
|
server.registerTool(
|
|
'get_workspace_id',
|
|
{
|
|
title: 'Get Workspace ID',
|
|
description: 'Get the current workspace ID',
|
|
inputSchema: z.object({}),
|
|
},
|
|
async () => {
|
|
const workspaceCtx = await getWorkspaceContext(ctx);
|
|
const workspaceId = await workspaceCtx.yaak.window.workspaceId();
|
|
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text' as const,
|
|
text: workspaceId || 'No workspace open',
|
|
},
|
|
],
|
|
};
|
|
},
|
|
);
|
|
|
|
server.registerTool(
|
|
'get_environment_id',
|
|
{
|
|
title: 'Get Environment ID',
|
|
description: 'Get the current environment ID',
|
|
inputSchema: z.object({}),
|
|
},
|
|
async () => {
|
|
const workspaceCtx = await getWorkspaceContext(ctx);
|
|
const environmentId = await workspaceCtx.yaak.window.environmentId();
|
|
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text' as const,
|
|
text: environmentId || 'No environment selected',
|
|
},
|
|
],
|
|
};
|
|
},
|
|
);
|
|
}
|