@attrove/mcp 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -3
- package/cjs/index.js +6 -1
- package/cjs/server.js +115 -56
- package/cjs/tools/events.js +134 -0
- package/cjs/tools/index.js +9 -1
- package/cjs/tools/integrations.js +11 -4
- package/cjs/tools/meetings.js +149 -0
- package/cjs/tools/query.js +12 -5
- package/cjs/tools/search.js +21 -7
- package/cjs/transport/http.js +192 -0
- package/esm/index.d.ts +3 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -1
- package/esm/index.js.map +1 -1
- package/esm/server.d.ts +7 -5
- package/esm/server.d.ts.map +1 -1
- package/esm/server.js +116 -57
- package/esm/server.js.map +1 -1
- package/esm/tools/events.d.ts +24 -0
- package/esm/tools/events.d.ts.map +1 -0
- package/esm/tools/events.js +131 -0
- package/esm/tools/events.js.map +1 -0
- package/esm/tools/index.d.ts +6 -69
- package/esm/tools/index.d.ts.map +1 -1
- package/esm/tools/index.js +5 -2
- package/esm/tools/index.js.map +1 -1
- package/esm/tools/integrations.d.ts +3 -10
- package/esm/tools/integrations.d.ts.map +1 -1
- package/esm/tools/integrations.js +11 -4
- package/esm/tools/integrations.js.map +1 -1
- package/esm/tools/meetings.d.ts +26 -0
- package/esm/tools/meetings.d.ts.map +1 -0
- package/esm/tools/meetings.js +146 -0
- package/esm/tools/meetings.js.map +1 -0
- package/esm/tools/query.d.ts +3 -27
- package/esm/tools/query.d.ts.map +1 -1
- package/esm/tools/query.js +12 -5
- package/esm/tools/query.js.map +1 -1
- package/esm/tools/search.d.ts +3 -35
- package/esm/tools/search.d.ts.map +1 -1
- package/esm/tools/search.js +21 -7
- package/esm/tools/search.js.map +1 -1
- package/esm/transport/http.d.ts +63 -0
- package/esm/transport/http.d.ts.map +1 -0
- package/esm/transport/http.js +189 -0
- package/esm/transport/http.js.map +1 -0
- package/package.json +2 -2
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export const integrationsToolDefinition = {
|
|
10
10
|
name: "attrove_integrations",
|
|
11
|
-
description: `List the user's connected integrations
|
|
11
|
+
description: `List the authenticated user's own connected integrations and their status.
|
|
12
12
|
|
|
13
|
-
This tool shows which services the user has connected
|
|
14
|
-
- Check what data sources
|
|
13
|
+
This read-only tool shows which services the user has explicitly connected to their account and each service's current status. Use this to:
|
|
14
|
+
- Check what data sources the user has authorized
|
|
15
15
|
- Verify integration status before searching
|
|
16
16
|
- Help users understand their connected services
|
|
17
17
|
|
|
@@ -24,9 +24,16 @@ The response includes:
|
|
|
24
24
|
properties: {},
|
|
25
25
|
required: [],
|
|
26
26
|
},
|
|
27
|
+
annotations: {
|
|
28
|
+
title: "List Integrations",
|
|
29
|
+
readOnlyHint: true,
|
|
30
|
+
destructiveHint: false,
|
|
31
|
+
idempotentHint: true,
|
|
32
|
+
openWorldHint: true,
|
|
33
|
+
},
|
|
27
34
|
};
|
|
28
35
|
/**
|
|
29
|
-
*
|
|
36
|
+
* List all connected integrations and format them for MCP display.
|
|
30
37
|
*/
|
|
31
38
|
export async function executeIntegrationsTool(client) {
|
|
32
39
|
const integrations = await client.integrations.list();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/integrations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/integrations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAS;IAC9C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE;;;;;;;;;;uEAUwD;IACrE,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;KACb;IACD,WAAW,EAAE;QACX,KAAK,EAAE,mBAAmB;QAC1B,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAAe;IAEf,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IAEtD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,mGAAmG,CAAC;IAC7G,CAAC;IAED,IAAI,MAAM,GAAG,2BAA2B,YAAY,CAAC,MAAM,MAAM,CAAC;IAElE,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC;QACjE,MAAM,UAAU,GACd,WAAW,CAAC,WAAW,KAAK,WAAW;YACrC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,KAAK,WAAW,CAAC,WAAW,GAAG,CAAC;QAEtC,MAAM,IAAI,SAAS,WAAW,CAAC,IAAI,OAAO,WAAW,CAAC,QAAQ,KAAK,CAAC;QACpE,MAAM,IAAI,WAAW,WAAW,CAAC,EAAE,IAAI,CAAC;QACxC,MAAM,IAAI,eAAe,MAAM,GAAG,UAAU,IAAI,CAAC;IACnD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meetings Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for listing meetings with AI-generated summaries and action items.
|
|
5
|
+
*/
|
|
6
|
+
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
import { Attrove, MeetingProvider } from "@attrove/sdk";
|
|
8
|
+
/**
|
|
9
|
+
* MCP schema for discovering and filtering meetings with AI-generated summaries.
|
|
10
|
+
*/
|
|
11
|
+
export declare const meetingsToolDefinition: Tool;
|
|
12
|
+
/**
|
|
13
|
+
* Validated input accepted by {@link executeMeetingsTool}.
|
|
14
|
+
*/
|
|
15
|
+
export interface MeetingsToolInput {
|
|
16
|
+
start_date?: string;
|
|
17
|
+
end_date?: string;
|
|
18
|
+
provider?: MeetingProvider;
|
|
19
|
+
limit?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fetch meetings via the SDK and format them as a human-readable summary
|
|
23
|
+
* including AI-generated summaries and action items.
|
|
24
|
+
*/
|
|
25
|
+
export declare function executeMeetingsTool(client: Attrove, input: MeetingsToolInput): Promise<string>;
|
|
26
|
+
//# sourceMappingURL=meetings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meetings.d.ts","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/meetings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EACL,OAAO,EAEP,eAAe,EAEhB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,IAyCpC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA+BD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,MAAM,CAAC,CAgFjB"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meetings Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for listing meetings with AI-generated summaries and action items.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* MCP schema for discovering and filtering meetings with AI-generated summaries.
|
|
8
|
+
*/
|
|
9
|
+
export const meetingsToolDefinition = {
|
|
10
|
+
name: "attrove_meetings",
|
|
11
|
+
description: `List meetings with AI-generated summaries and action items from the user's own connected accounts.
|
|
12
|
+
|
|
13
|
+
This read-only tool returns meetings from the authenticated user's authorized meeting integrations (e.g., Google Meet, Zoom, Teams) with AI-generated summaries. Only meetings from services the user has explicitly connected are accessed. Use this when the user asks about:
|
|
14
|
+
- "What happened in my last meeting?"
|
|
15
|
+
- "Summarize yesterday's standup"
|
|
16
|
+
- "What are the action items from the product review?"
|
|
17
|
+
- "Show me my recent meetings"`,
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: "object",
|
|
20
|
+
properties: {
|
|
21
|
+
start_date: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Start of date range (ISO 8601). If omitted, the server determines the default.",
|
|
24
|
+
},
|
|
25
|
+
end_date: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "End of date range (ISO 8601). If omitted, the server determines the default.",
|
|
28
|
+
},
|
|
29
|
+
provider: {
|
|
30
|
+
type: "string",
|
|
31
|
+
enum: ["google_meet", "zoom", "teams"],
|
|
32
|
+
description: "Optional: Filter by meeting provider",
|
|
33
|
+
},
|
|
34
|
+
limit: {
|
|
35
|
+
type: "number",
|
|
36
|
+
description: "Max meetings to return (default 10, max 50)",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: [],
|
|
40
|
+
},
|
|
41
|
+
annotations: {
|
|
42
|
+
title: "Meeting Summaries",
|
|
43
|
+
readOnlyHint: true,
|
|
44
|
+
destructiveHint: false,
|
|
45
|
+
idempotentHint: true,
|
|
46
|
+
openWorldHint: true,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Format a meeting's time range for display.
|
|
51
|
+
* Returns a fallback string when the meeting contains unparseable dates.
|
|
52
|
+
*/
|
|
53
|
+
function formatMeetingTime(meeting) {
|
|
54
|
+
const start = new Date(meeting.start_time);
|
|
55
|
+
const end = new Date(meeting.end_time);
|
|
56
|
+
if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime())) {
|
|
57
|
+
return meeting.start_time ?? "Unknown time";
|
|
58
|
+
}
|
|
59
|
+
const dateStr = start.toLocaleDateString(undefined, {
|
|
60
|
+
weekday: "short",
|
|
61
|
+
month: "short",
|
|
62
|
+
day: "numeric",
|
|
63
|
+
});
|
|
64
|
+
const startTime = start.toLocaleTimeString(undefined, {
|
|
65
|
+
hour: "numeric",
|
|
66
|
+
minute: "2-digit",
|
|
67
|
+
});
|
|
68
|
+
const endTime = end.toLocaleTimeString(undefined, {
|
|
69
|
+
hour: "numeric",
|
|
70
|
+
minute: "2-digit",
|
|
71
|
+
});
|
|
72
|
+
return `${dateStr}, ${startTime} – ${endTime}`;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Fetch meetings via the SDK and format them as a human-readable summary
|
|
76
|
+
* including AI-generated summaries and action items.
|
|
77
|
+
*/
|
|
78
|
+
export async function executeMeetingsTool(client, input) {
|
|
79
|
+
const options = {
|
|
80
|
+
expand: ["summary", "short_summary", "action_items", "attendees"],
|
|
81
|
+
};
|
|
82
|
+
if (input.start_date) {
|
|
83
|
+
options.startDate = input.start_date;
|
|
84
|
+
}
|
|
85
|
+
if (input.end_date) {
|
|
86
|
+
options.endDate = input.end_date;
|
|
87
|
+
}
|
|
88
|
+
if (input.provider) {
|
|
89
|
+
options.provider = input.provider;
|
|
90
|
+
}
|
|
91
|
+
options.limit = Math.max(1, Math.min(input.limit ?? 10, 50));
|
|
92
|
+
const response = await client.meetings.list(options);
|
|
93
|
+
if (!response.data) {
|
|
94
|
+
// prettier-ignore
|
|
95
|
+
console.error("[AttroveMCP]", JSON.stringify({ level: "warn", msg: "Meetings API returned success but data was nullish", errorId: "MCP_MEETINGS_MALFORMED_RESPONSE" }));
|
|
96
|
+
return "The meetings API returned an unexpected response format. Please try again.";
|
|
97
|
+
}
|
|
98
|
+
if (response.data.length === 0) {
|
|
99
|
+
return "No meetings found for the specified date range.";
|
|
100
|
+
}
|
|
101
|
+
const meetings = response.data;
|
|
102
|
+
let result = `Found ${meetings.length} meeting(s):\n`;
|
|
103
|
+
for (const meeting of meetings) {
|
|
104
|
+
result += `\n### ${meeting.title}\n`;
|
|
105
|
+
result += `- **When:** ${formatMeetingTime(meeting)}\n`;
|
|
106
|
+
if (meeting.provider) {
|
|
107
|
+
const providerLabel = meeting.provider
|
|
108
|
+
.replace(/_/g, " ")
|
|
109
|
+
.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
110
|
+
result += `- **Provider:** ${providerLabel}\n`;
|
|
111
|
+
}
|
|
112
|
+
if (meeting.attendees?.length) {
|
|
113
|
+
const attendeeList = meeting.attendees
|
|
114
|
+
.map((a) => {
|
|
115
|
+
const name = a.name || a.email || "Unknown";
|
|
116
|
+
const role = a.is_organizer ? " (organizer)" : "";
|
|
117
|
+
return `${name}${role}`;
|
|
118
|
+
})
|
|
119
|
+
.join(", ");
|
|
120
|
+
result += `- **Attendees:** ${attendeeList}\n`;
|
|
121
|
+
}
|
|
122
|
+
if (meeting.meeting_link) {
|
|
123
|
+
result += `- **Meeting link:** ${meeting.meeting_link}\n`;
|
|
124
|
+
}
|
|
125
|
+
if (meeting.summary) {
|
|
126
|
+
result += `\n**Summary:**\n${meeting.summary}\n`;
|
|
127
|
+
}
|
|
128
|
+
else if (meeting.short_summary) {
|
|
129
|
+
result += `\n**Summary:** ${meeting.short_summary}\n`;
|
|
130
|
+
}
|
|
131
|
+
if (meeting.action_items?.length) {
|
|
132
|
+
result += `\n**Action Items:**\n`;
|
|
133
|
+
for (const item of meeting.action_items) {
|
|
134
|
+
const assignee = item.assignee ? ` (${item.assignee})` : "";
|
|
135
|
+
const dueDate = item.due_date ? ` — due ${item.due_date}` : "";
|
|
136
|
+
const status = item.completed ? " [Done]" : "";
|
|
137
|
+
result += `- ${item.description}${assignee}${dueDate}${status}\n`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (response.pagination?.has_more) {
|
|
142
|
+
result += `\n_Showing ${meetings.length} of ${response.pagination.total_count ?? "more"} meetings. Adjust start_date, end_date, or limit to refine results._\n`;
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=meetings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meetings.js","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/meetings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAS;IAC1C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE;;;;;;+BAMgB;IAC7B,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,gFAAgF;aACnF;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,8EAA8E;aACjF;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC;gBACtC,WAAW,EAAE,sCAAsC;aACpD;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6CAA6C;aAC3D;SACF;QACD,QAAQ,EAAE,EAAE;KACb;IACD,WAAW,EAAE;QACX,KAAK,EAAE,mBAAmB;QAC1B,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB;CACF,CAAC;AAYF;;;GAGG;AACH,SAAS,iBAAiB,CAAC,OAAgB;IACzC,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IA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AAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/C,MAAM,IAAI,KAAK,IAAI,CAAC,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,IAAI,CAAC;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC;QAClC,MAAM,IAAI,cAAc,QAAQ,CAAC,MAAM,OAAO,QAAQ,CAAC,UAAU,CAAC,WAAW,IAAI,MAAM,wEAAwE,CAAC;IAClK,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/esm/tools/query.d.ts
CHANGED
|
@@ -3,36 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* MCP tool for RAG queries against user context.
|
|
5
5
|
*/
|
|
6
|
+
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
6
7
|
import { Attrove } from "@attrove/sdk";
|
|
7
8
|
/**
|
|
8
9
|
* Tool definition for attrove_query.
|
|
9
10
|
*/
|
|
10
|
-
export declare const queryToolDefinition:
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
inputSchema: {
|
|
14
|
-
type: "object";
|
|
15
|
-
properties: {
|
|
16
|
-
query: {
|
|
17
|
-
type: string;
|
|
18
|
-
description: string;
|
|
19
|
-
};
|
|
20
|
-
integration_ids: {
|
|
21
|
-
type: string;
|
|
22
|
-
items: {
|
|
23
|
-
type: string;
|
|
24
|
-
};
|
|
25
|
-
description: string;
|
|
26
|
-
};
|
|
27
|
-
include_sources: {
|
|
28
|
-
type: string;
|
|
29
|
-
description: string;
|
|
30
|
-
default: boolean;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
required: string[];
|
|
34
|
-
};
|
|
35
|
-
};
|
|
11
|
+
export declare const queryToolDefinition: Tool;
|
|
36
12
|
/**
|
|
37
13
|
* Input for the query tool.
|
|
38
14
|
*/
|
|
@@ -42,7 +18,7 @@ export interface QueryToolInput {
|
|
|
42
18
|
include_sources?: boolean;
|
|
43
19
|
}
|
|
44
20
|
/**
|
|
45
|
-
*
|
|
21
|
+
* Run a RAG query via the SDK and format the answer with optional sources.
|
|
46
22
|
*/
|
|
47
23
|
export declare function executeQueryTool(client: Attrove, input: QueryToolInput): Promise<string>;
|
|
48
24
|
//# sourceMappingURL=query.d.ts.map
|
package/esm/tools/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAA+B,MAAM,cAAc,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAA+B,MAAM,cAAc,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,IAsCjC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,MAAM,CAAC,CA2BjB"}
|
package/esm/tools/query.js
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export const queryToolDefinition = {
|
|
10
10
|
name: "attrove_query",
|
|
11
|
-
description: `Ask a question
|
|
11
|
+
description: `Ask a question and get an AI-generated answer from the user's own connected accounts.
|
|
12
12
|
|
|
13
|
-
This tool searches
|
|
13
|
+
This read-only tool searches the authenticated user's connected services (e.g., Gmail, Slack, Google Calendar) and returns an answer based on their own data. Only data the user has explicitly connected and authorized is accessed.
|
|
14
14
|
|
|
15
15
|
Use this tool when the user asks questions like:
|
|
16
16
|
- "What did Sarah say about the Q4 budget?"
|
|
17
17
|
- "Summarize my meeting with the engineering team"
|
|
18
18
|
- "What are the action items from yesterday's standup?"
|
|
19
|
-
- "
|
|
19
|
+
- "What context do I need for my 3pm meeting?"`,
|
|
20
20
|
inputSchema: {
|
|
21
21
|
type: "object",
|
|
22
22
|
properties: {
|
|
@@ -37,9 +37,16 @@ Use this tool when the user asks questions like:
|
|
|
37
37
|
},
|
|
38
38
|
required: ["query"],
|
|
39
39
|
},
|
|
40
|
+
annotations: {
|
|
41
|
+
title: "Ask Attrove",
|
|
42
|
+
readOnlyHint: true,
|
|
43
|
+
destructiveHint: false,
|
|
44
|
+
idempotentHint: true,
|
|
45
|
+
openWorldHint: true,
|
|
46
|
+
},
|
|
40
47
|
};
|
|
41
48
|
/**
|
|
42
|
-
*
|
|
49
|
+
* Run a RAG query via the SDK and format the answer with optional sources.
|
|
43
50
|
*/
|
|
44
51
|
export async function executeQueryTool(client, input) {
|
|
45
52
|
const options = {};
|
|
@@ -58,7 +65,7 @@ export async function executeQueryTool(client, input) {
|
|
|
58
65
|
result += `\n- ${source.title}: "${source.snippet}"`;
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
|
-
if (response.used_message_ids
|
|
68
|
+
if (response.used_message_ids?.length) {
|
|
62
69
|
result += `\n\n_Based on ${response.used_message_ids.length} messages._`;
|
|
63
70
|
}
|
|
64
71
|
return result;
|
package/esm/tools/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/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,MAAM,EAAE,CAAC;QAC7B,MAAM,IAAI,kBAAkB,CAAC;QAC7B,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtC,MAAM,IAAI,OAAO,MAAM,CAAC,KAAK,MAAM,MAAM,CAAC,OAAO,GAAG,CAAC;QACvD,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;QACtC,MAAM,IAAI,iBAAiB,QAAQ,CAAC,gBAAgB,CAAC,MAAM,aAAa,CAAC;IAC3E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/esm/tools/search.d.ts
CHANGED
|
@@ -3,44 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* MCP tool for semantic search across user context.
|
|
5
5
|
*/
|
|
6
|
+
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
6
7
|
import { Attrove } from "@attrove/sdk";
|
|
7
8
|
/**
|
|
8
9
|
* Tool definition for attrove_search.
|
|
9
10
|
*/
|
|
10
|
-
export declare const searchToolDefinition:
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
inputSchema: {
|
|
14
|
-
type: "object";
|
|
15
|
-
properties: {
|
|
16
|
-
query: {
|
|
17
|
-
type: string;
|
|
18
|
-
description: string;
|
|
19
|
-
};
|
|
20
|
-
after_date: {
|
|
21
|
-
type: string;
|
|
22
|
-
description: string;
|
|
23
|
-
};
|
|
24
|
-
before_date: {
|
|
25
|
-
type: string;
|
|
26
|
-
description: string;
|
|
27
|
-
};
|
|
28
|
-
sender_domains: {
|
|
29
|
-
type: string;
|
|
30
|
-
items: {
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
description: string;
|
|
34
|
-
};
|
|
35
|
-
include_body_text: {
|
|
36
|
-
type: string;
|
|
37
|
-
description: string;
|
|
38
|
-
default: boolean;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
required: string[];
|
|
42
|
-
};
|
|
43
|
-
};
|
|
11
|
+
export declare const searchToolDefinition: Tool;
|
|
44
12
|
/**
|
|
45
13
|
* Input for the search tool.
|
|
46
14
|
*/
|
|
@@ -52,7 +20,7 @@ export interface SearchToolInput {
|
|
|
52
20
|
include_body_text?: boolean;
|
|
53
21
|
}
|
|
54
22
|
/**
|
|
55
|
-
*
|
|
23
|
+
* Search user messages via the SDK and format results grouped by conversation.
|
|
56
24
|
*/
|
|
57
25
|
export declare function executeSearchTool(client: Attrove, input: SearchToolInput): Promise<string>;
|
|
58
26
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,OAAO,EAIR,MAAM,cAAc,CAAC;AAGtB;;GAEG;AACH,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EACL,OAAO,EAIR,MAAM,cAAc,CAAC;AAGtB;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,IAqDlC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,MAAM,CAAC,CAqHjB"}
|
package/esm/tools/search.js
CHANGED
|
@@ -9,10 +9,10 @@ import { MAX_BODY_PREVIEW_LENGTH } from "../constants.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export const searchToolDefinition = {
|
|
11
11
|
name: "attrove_search",
|
|
12
|
-
description: `Search for
|
|
12
|
+
description: `Search for messages or conversations in the user's own connected accounts.
|
|
13
13
|
|
|
14
|
-
This tool performs semantic search across connected
|
|
15
|
-
-
|
|
14
|
+
This read-only tool performs semantic search across the authenticated user's connected services and returns matching messages grouped by conversation. Only the user's own authorized data is searched. Use this when you need:
|
|
15
|
+
- Message data without AI summarization
|
|
16
16
|
- To find specific conversations or threads
|
|
17
17
|
- To explore what information is available about a topic
|
|
18
18
|
|
|
@@ -42,15 +42,23 @@ Use this tool when the user asks things like:
|
|
|
42
42
|
},
|
|
43
43
|
include_body_text: {
|
|
44
44
|
type: "boolean",
|
|
45
|
-
|
|
45
|
+
// NOTE: The "200 characters" must match MAX_BODY_PREVIEW_LENGTH in constants.ts
|
|
46
|
+
description: "Optional: Include message body text preview (truncated to 200 characters)",
|
|
46
47
|
default: true,
|
|
47
48
|
},
|
|
48
49
|
},
|
|
49
50
|
required: ["query"],
|
|
50
51
|
},
|
|
52
|
+
annotations: {
|
|
53
|
+
title: "Search Messages",
|
|
54
|
+
readOnlyHint: true,
|
|
55
|
+
destructiveHint: false,
|
|
56
|
+
idempotentHint: true,
|
|
57
|
+
openWorldHint: true,
|
|
58
|
+
},
|
|
51
59
|
};
|
|
52
60
|
/**
|
|
53
|
-
*
|
|
61
|
+
* Search user messages via the SDK and format results grouped by conversation.
|
|
54
62
|
*/
|
|
55
63
|
export async function executeSearchTool(client, input) {
|
|
56
64
|
const options = {
|
|
@@ -82,17 +90,21 @@ export async function executeSearchTool(client, input) {
|
|
|
82
90
|
let skippedThreads = 0;
|
|
83
91
|
let skippedMessages = 0;
|
|
84
92
|
for (const [convId, conv] of Object.entries(response.conversations)) {
|
|
85
|
-
// Skip malformed conversation entries
|
|
93
|
+
// Skip malformed conversation entries - may occur with API version mismatches or partial responses
|
|
86
94
|
if (!conv || !conv.threads) {
|
|
87
95
|
skippedConversations++;
|
|
96
|
+
// prettier-ignore
|
|
97
|
+
console.error("[AttroveMCP]", JSON.stringify({ level: "warn", msg: "Search skipped malformed conversation", errorId: "MCP_SEARCH_MALFORMED_CONVERSATION", conversationId: convId, hasConv: !!conv, hasThreads: !!(conv?.threads) }));
|
|
88
98
|
continue;
|
|
89
99
|
}
|
|
90
100
|
const convName = conv.conversation_name || `Conversation ${convId}`;
|
|
91
101
|
result += `\n## ${convName}\n`;
|
|
92
102
|
for (const [threadId, messages] of Object.entries(conv.threads)) {
|
|
93
|
-
// Skip malformed thread entries
|
|
103
|
+
// Skip malformed thread entries - may occur with API version mismatches or partial responses
|
|
94
104
|
if (!Array.isArray(messages)) {
|
|
95
105
|
skippedThreads++;
|
|
106
|
+
// prettier-ignore
|
|
107
|
+
console.error("[AttroveMCP]", JSON.stringify({ level: "warn", msg: "Search skipped malformed thread", errorId: "MCP_SEARCH_MALFORMED_THREAD", conversationId: convId, threadId, messagesType: typeof messages }));
|
|
96
108
|
continue;
|
|
97
109
|
}
|
|
98
110
|
if (messages.length > 1) {
|
|
@@ -101,6 +113,8 @@ export async function executeSearchTool(client, input) {
|
|
|
101
113
|
for (const msg of messages) {
|
|
102
114
|
if (!msg) {
|
|
103
115
|
skippedMessages++;
|
|
116
|
+
// prettier-ignore
|
|
117
|
+
console.error("[AttroveMCP]", JSON.stringify({ level: "warn", msg: "Search skipped null message", errorId: "MCP_SEARCH_NULL_MESSAGE", conversationId: convId, threadId }));
|
|
104
118
|
continue;
|
|
105
119
|
}
|
|
106
120
|
// Defensive date formatting to handle invalid dates gracefully
|
package/esm/tools/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../../packages/mcp/src/tools/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../../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C7B,QAAQ,CAAC,IAAI,CAAC,GAAG,oBAAoB,kBAAkB,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,GAAG,cAAc,YAAY,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,GAAG,eAAe,aAAa,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,IAAI,iBAAiB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,qCAAqC,CAAC;IACtF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Transport for Attrove MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Provides HTTP-based transport for the MCP server, enabling AI assistants
|
|
5
|
+
* like ChatGPT to connect via HTTP endpoints instead of stdio.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
9
|
+
import { McpServerConfig } from "../server.js";
|
|
10
|
+
/**
|
|
11
|
+
* Result when MCP request was successfully processed by the transport.
|
|
12
|
+
* Note: This indicates the transport handled the request, not that the MCP operation succeeded.
|
|
13
|
+
*/
|
|
14
|
+
interface McpHttpHandlerSuccess {
|
|
15
|
+
handled: true;
|
|
16
|
+
/** True if server cleanup failed after handling the request (potential resource leak) */
|
|
17
|
+
cleanupFailed?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Result when MCP request could not be processed.
|
|
21
|
+
* When this is returned, no HTTP response has been sent - the caller must
|
|
22
|
+
* send an appropriate error response to the client.
|
|
23
|
+
*/
|
|
24
|
+
interface McpHttpHandlerFailure {
|
|
25
|
+
handled: false;
|
|
26
|
+
error: string;
|
|
27
|
+
/** Full stack trace if available, for logging */
|
|
28
|
+
stack?: string;
|
|
29
|
+
/** True if the failure was due to timeout */
|
|
30
|
+
isTimeout: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Discriminated union for MCP HTTP handler results.
|
|
34
|
+
* Use `result.handled` to narrow the type.
|
|
35
|
+
*/
|
|
36
|
+
export type McpHttpHandlerResult = McpHttpHandlerSuccess | McpHttpHandlerFailure;
|
|
37
|
+
export type { McpHttpHandlerFailure };
|
|
38
|
+
/**
|
|
39
|
+
* Configuration options for the HTTP handler.
|
|
40
|
+
*/
|
|
41
|
+
export interface CreateHttpHandlerOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Enable JSON response mode instead of SSE streaming.
|
|
44
|
+
* When true, responses are returned as JSON objects.
|
|
45
|
+
* When false, responses use Server-Sent Events streaming.
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
enableJsonResponse?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Request timeout in milliseconds.
|
|
51
|
+
* Prevents requests from hanging indefinitely if MCP tools make slow external calls.
|
|
52
|
+
* @default 30000 (30 seconds)
|
|
53
|
+
*/
|
|
54
|
+
timeoutMs?: number;
|
|
55
|
+
}
|
|
56
|
+
export declare function createHttpHandler(config: McpServerConfig, options?: CreateHttpHandlerOptions): McpHttpHandler;
|
|
57
|
+
/**
|
|
58
|
+
* HTTP handler interface for processing MCP requests.
|
|
59
|
+
*/
|
|
60
|
+
export interface McpHttpHandler {
|
|
61
|
+
handleRequest: (req: IncomingMessage, res: ServerResponse, parsedBody?: unknown) => Promise<McpHttpHandlerResult>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../packages/mcp/src/transport/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG5D,OAAO,EAAgB,eAAe,EAAE,MAAM,cAAc,CAAC;AAE7D;;;GAGG;AACH,UAAU,qBAAqB;IAC7B,OAAO,EAAE,IAAI,CAAC;IACd,yFAAyF;IACzF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,UAAU,qBAAqB;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC5B,qBAAqB,GACrB,qBAAqB,CAAC;AAG1B,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAqCD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,wBAA6B,GACrC,cAAc,CAsKhB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,CACb,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,UAAU,CAAC,EAAE,OAAO,KACjB,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACpC"}
|