@theronap/cortex-mcp 0.9.93 → 0.9.94

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.
Files changed (2) hide show
  1. package/lib/server.mjs +34 -0
  2. package/package.json +1 -1
package/lib/server.mjs CHANGED
@@ -916,6 +916,40 @@ export async function runServer(version) {
916
916
  },
917
917
  )
918
918
 
919
+ server.registerTool(
920
+ 'search_spam_email',
921
+ {
922
+ title: 'Search Gmail Spam intentionally',
923
+ description: 'Search a connected Gmail Spam folder only when the user explicitly asks you to find a message that may have been marked as Spam. This is read-only: results are returned for this request only and are NOT added to Agnoclast records, timeline, or future context. Give a specific Gmail search such as a sender, subject words, or date. Normal Gmail sync never reads Spam.',
924
+ inputSchema: {
925
+ query: z.string().min(2).describe('specific Gmail search within Spam, e.g. `from:billing@example.com`, `subject:(appointment reminder)`, or `after:2026/08/01`'),
926
+ account: z.string().email().optional().describe('which connected Gmail account to search when more than one is available'),
927
+ limit: z.number().int().min(1).max(10).optional().describe('maximum matches to return (default 5; max 10)'),
928
+ },
929
+ },
930
+ async ({ query, account, limit }) => {
931
+ const res = await fetchCortex(`${BASE}/api/gmail/search-spam`, {
932
+ method: 'POST',
933
+ headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
934
+ body: JSON.stringify({ query, ...(account ? { account } : {}), ...(limit ? { limit } : {}) }),
935
+ })
936
+ const body = await res.json().catch(() => null)
937
+ if (!res.ok) {
938
+ if (res.status === 409 && Array.isArray(body?.accounts)) {
939
+ return toolError(`Choose a connected Gmail account and call again with account: ${body.accounts.join(', ')}`)
940
+ }
941
+ return toolError(body?.error ?? `Spam search failed (${res.status}).`)
942
+ }
943
+ const rows = Array.isArray(body?.messages) ? body.messages : []
944
+ if (!rows.length) return { content: [{ type: 'text', text: `No Spam matches in ${body?.account ?? 'the connected Gmail account'}. Nothing was saved to Agnoclast.` }] }
945
+ const lines = [`Spam matches in ${body.account} (read-only; not saved to Agnoclast):`]
946
+ for (const m of rows) {
947
+ lines.push(`- ${m.date || 'unknown date'} · ${m.from || 'unknown sender'} · ${m.subject}\n ${m.snippet || '(no preview)'}\n ${m.sourceUri}`)
948
+ }
949
+ return { content: [{ type: 'text', text: lines.join('\n') }] }
950
+ },
951
+ )
952
+
919
953
  server.registerTool(
920
954
  'grep',
921
955
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/cortex-mcp",
3
- "version": "0.9.93",
3
+ "version": "0.9.94",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {