mcp-tess
Version:
MCP server for executing Tess AI api
338 lines • 11.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
const zod_1 = require("zod");
const index_1 = require("./services/tess/index");
const server = new mcp_js_1.McpServer({
name: "mcp-tess",
version: "1.0.0",
});
server.tool("execute_agent", "Execute a Tess AI agent with a message", {
agentId: zod_1.z.number().describe("The ID of the Tess agent to execute"),
rootId: zod_1.z.number().optional().describe("The root ID of the execution, used to create a conversation (default: null)"),
message: zod_1.z.string().describe("The message/prompt to send to the agent"),
temperature: zod_1.z.enum(["0", "0.25", "0.5", "0.75", "1"]).optional().describe("Temperature for the model (default: '1')"),
model: zod_1.z.string().optional().describe("Model to use (default: 'tess-5')"),
tools: zod_1.z.string().optional().describe("Tools setting (default: 'no-tools')"),
fileIds: zod_1.z.array(zod_1.z.number()).optional().describe("Array of file IDs to attach to the execution"),
memoryCollections: zod_1.z.array(zod_1.z.number()).optional().describe("Array of memory collection IDs to attach to the execution"),
}, async (args) => {
try {
const { agentId, rootId, message, temperature, model, tools, fileIds, memoryCollections } = args;
const messages = [{ role: "user", content: message }];
const result = await (0, index_1.executeAgent)(agentId, messages, temperature, model, tools, fileIds, rootId, memoryCollections);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error executing Tess agent: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("list_agents", "List all available Tess AI agents", {
page: zod_1.z.number().optional().describe("The page number to list (default: 1)"),
perPage: zod_1.z.number().optional().describe("The number of items per page (default: 10)"),
search: zod_1.z.string().optional().describe("The search query to filter agents (default: null)"),
type: zod_1.z.enum(['chat', 'image', 'text', 'video']).optional().describe("The type of agent to filter (default: null)"),
}, async (args) => {
try {
const { page, perPage, search, type } = args;
const result = await (0, index_1.listAgents)({ q: search, type, page, per_page: perPage });
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error listing Tess agents: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("get_agent", "Get detailed information about a specific Tess AI agent", {
agentId: zod_1.z.number().describe("The ID of the Tess agent to get information about")
}, async (args) => {
try {
const { agentId } = args;
console.error("get-tess-agent", agentId);
const result = await (0, index_1.getAgent)(agentId);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error getting Tess agent: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("create_memory", "Create a new memory in a collection", {
collectionId: zod_1.z.number().optional().describe("The collection ID to create the memory in (default: null)"),
memory: zod_1.z.string().max(32000).describe("The memory content"),
}, async (args) => {
try {
const { collectionId, memory } = args;
const result = await (0, index_1.createMemory)(memory, collectionId);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error creating Tess memory: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("update_memory", "Update a memory in a collection", {
memoryId: zod_1.z.number().describe("The ID of the memory to update"),
memory: zod_1.z.string().max(32000).describe("The memory content"),
collectionId: zod_1.z.number().optional().describe("The collection ID to update the memory in (default: null)"),
}, async (args) => {
try {
const { memoryId, memory, collectionId } = args;
const result = await (0, index_1.updateMemory)(memoryId, memory, collectionId);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error updating Tess memory: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("delete_memory", "Delete a memory", {
memoryId: zod_1.z.number().describe("The ID of the memory to delete"),
}, async (args) => {
try {
const { memoryId } = args;
const result = await (0, index_1.deleteMemory)(memoryId);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error deleting Tess memory: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("list_memories", "List memories with optional pagination and filtering", {
page: zod_1.z.number().optional().describe("The page number to list (default: 1)"),
perPage: zod_1.z.number().min(1).max(50).optional().describe("The number of items per page (default: 10, min: 1, max: 50)"),
collectionId: zod_1.z.number().optional().describe("Filter by collection ID (default: null)"),
}, async (args) => {
try {
const { page, perPage, collectionId } = args;
const result = await (0, index_1.listMemories)(page, perPage, collectionId);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error listing Tess memories: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("list_memory_collections", "List all memory collections", {
page: zod_1.z.number().optional().describe("The page number to list (default: 1)"),
perPage: zod_1.z.number().optional().describe("The number of items per page (default: 10)"),
search: zod_1.z.string().optional().describe("The search query to filter collections (default: null)"),
}, async (args) => {
try {
const { page, perPage, search } = args;
const result = await (0, index_1.listMemoryCollections)(page, perPage, search);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error listing Tess memory collections: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("create_memory_collection", "Create a new memory collection", {
name: zod_1.z.string().describe("The name of the collection"),
}, async (args) => {
try {
const { name } = args;
const result = await (0, index_1.createMemoryCollection)(name);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error creating Tess memory collection: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("update_memory_collection", "Update a memory collection", {
collectionId: zod_1.z.number().describe("The ID of the collection to update"),
name: zod_1.z.string().describe("The name of the collection"),
}, async (args) => {
try {
const { collectionId, name } = args;
const result = await (0, index_1.updateMemoryCollection)(collectionId, name);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error updating Tess memory collection: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
server.tool("delete_memory_collection", "Delete a memory collection", {
collectionId: zod_1.z.number().describe("The ID of the collection to delete"),
}, async (args) => {
try {
const { collectionId } = args;
const result = await (0, index_1.deleteMemoryCollection)(collectionId);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error deleting Tess memory collection: ${error instanceof Error ? error.message : String(error)}`
}
],
isError: true
};
}
});
async function main() {
const transport = new stdio_js_1.StdioServerTransport();
await server.connect(transport);
console.error("Tess MCP server running on stdio");
}
main().catch((error) => {
console.error("Fatal error in main():", error);
process.exit(1);
});
//# sourceMappingURL=index.js.map