agent-ecosystem/mcp-server/src/tools/messageTools.ts
iliya d486510c9e refactor: update package.json scripts and enhance CI workflow
- Renamed the 'check' script to 'check:workspace' for clarity and updated the main 'check' script to include linting.
- Modified CI workflow to monitor changes in the '.github/workflows/**' and 'pnpm-workspace.yaml' files, ensuring better integration and tracking.
- Added new tests to validate task lifecycle and review processes, enhancing overall test coverage and reliability.
2026-03-07 19:09:58 +02:00

60 lines
1.5 KiB
TypeScript

import type { FastMCP } from 'fastmcp';
import { z } from 'zod';
import { getController } from '../controller';
import { jsonTextContent } from '../utils/format';
const toolContextSchema = {
teamName: z.string().min(1),
claudeDir: z.string().min(1).optional(),
};
export function registerMessageTools(server: Pick<FastMCP, 'addTool'>) {
server.addTool({
name: 'message_send',
description: 'Send a message into team inbox',
parameters: z.object({
...toolContextSchema,
to: z.string().min(1),
text: z.string().min(1),
from: z.string().optional(),
summary: z.string().optional(),
source: z.string().optional(),
leadSessionId: z.string().optional(),
attachments: z
.array(
z.object({
id: z.string().min(1),
filename: z.string().min(1),
mimeType: z.string().min(1),
size: z.number().nonnegative(),
})
)
.optional(),
}),
execute: async ({
teamName,
claudeDir,
to,
text,
from,
summary,
source,
leadSessionId,
attachments,
}) =>
await Promise.resolve(
jsonTextContent(
getController(teamName, claudeDir).messages.sendMessage({
to,
text,
...(from ? { from } : {}),
...(summary ? { summary } : {}),
...(source ? { source } : {}),
...(leadSessionId ? { leadSessionId } : {}),
...(attachments?.length ? { attachments } : {}),
})
)
),
});
}