limitless-ai-mcp-server
Version:
MCP server for integrating Limitless AI Pendant recordings with AI assistants
136 lines • 4.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolHandlers = void 0;
const schemas_1 = require("./schemas");
const logger_1 = require("../utils/logger");
const format_1 = require("../utils/format");
class ToolHandlers {
client;
constructor(client) {
this.client = client;
}
async handleToolCall(request) {
const { name, arguments: args } = request.params;
logger_1.logger.debug(`Handling tool call: ${name}`, args);
try {
switch (name) {
case 'limitless_get_lifelog_by_id':
return await this.getLifelogById(args);
case 'limitless_list_lifelogs_by_date':
return await this.listLifelogsByDate(args);
case 'limitless_list_lifelogs_by_range':
return await this.listLifelogsByRange(args);
case 'limitless_list_recent_lifelogs':
return await this.listRecentLifelogs(args);
case 'limitless_search_lifelogs':
return await this.searchLifelogs(args);
default:
throw new Error(`Unknown tool: ${name}`);
}
}
catch (error) {
logger_1.logger.error(`Tool call failed: ${name}`, error);
return {
content: [
{
type: 'text',
text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`,
},
],
isError: true,
};
}
}
async getLifelogById(args) {
const params = schemas_1.getLifelogByIdSchema.parse(args);
const lifelog = await this.client.getLifelogById(params.lifelog_id, {
includeMarkdown: params.includeMarkdown,
includeHeadings: params.includeHeadings,
});
return {
content: [
{
type: 'text',
text: (0, format_1.formatLifelogResponse)([lifelog], params),
},
],
};
}
async listLifelogsByDate(args) {
const params = schemas_1.listLifelogsByDateSchema.parse(args);
const lifelogs = await this.client.listLifelogsByDate(params.date, {
limit: params.limit,
direction: params.direction,
timezone: params.timezone,
includeMarkdown: params.includeMarkdown,
includeHeadings: params.includeHeadings,
});
return {
content: [
{
type: 'text',
text: (0, format_1.formatLifelogResponse)(lifelogs, params),
},
],
};
}
async listLifelogsByRange(args) {
const params = schemas_1.listLifelogsByRangeSchema.parse(args);
const lifelogs = await this.client.listLifelogsByRange({
start: params.start,
end: params.end,
limit: params.limit,
direction: params.direction,
timezone: params.timezone,
includeMarkdown: params.includeMarkdown,
includeHeadings: params.includeHeadings,
});
return {
content: [
{
type: 'text',
text: (0, format_1.formatLifelogResponse)(lifelogs, params),
},
],
};
}
async listRecentLifelogs(args) {
const params = schemas_1.listRecentLifelogsSchema.parse(args);
const lifelogs = await this.client.listRecentLifelogs({
limit: params.limit,
timezone: params.timezone,
includeMarkdown: params.includeMarkdown,
includeHeadings: params.includeHeadings,
});
return {
content: [
{
type: 'text',
text: (0, format_1.formatLifelogResponse)(lifelogs, params),
},
],
};
}
async searchLifelogs(args) {
const params = schemas_1.searchLifelogsSchema.parse(args);
const lifelogs = await this.client.searchLifelogs({
searchTerm: params.search_term,
fetchLimit: params.fetch_limit,
limit: params.limit,
direction: params.direction,
timezone: params.timezone,
includeMarkdown: params.includeMarkdown,
includeHeadings: params.includeHeadings,
});
return {
content: [
{
type: 'text',
text: (0, format_1.formatLifelogResponse)(lifelogs, params, params.search_term),
},
],
};
}
}
exports.ToolHandlers = ToolHandlers;
//# sourceMappingURL=handlers.js.map