@attrove/mcp 0.1.2 → 0.1.4

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 (53) hide show
  1. package/README.md +52 -1
  2. package/cjs/README.md +247 -0
  3. package/cjs/bin/attrove-mcp.js +69 -0
  4. package/cjs/package.json +69 -0
  5. package/cjs/src/__mocks__/version.js +17 -0
  6. package/cjs/src/__mocks__/version.js.map +1 -0
  7. package/cjs/src/constants.js +17 -0
  8. package/cjs/src/constants.js.map +1 -0
  9. package/cjs/src/index.js +43 -0
  10. package/cjs/src/index.js.map +1 -0
  11. package/cjs/src/server.js +247 -0
  12. package/cjs/src/server.js.map +1 -0
  13. package/cjs/src/tools/index.js +26 -0
  14. package/cjs/src/tools/index.js.map +1 -0
  15. package/cjs/src/tools/integrations.js +50 -0
  16. package/cjs/src/tools/integrations.js.map +1 -0
  17. package/cjs/src/tools/query.js +70 -0
  18. package/cjs/src/tools/query.js.map +1 -0
  19. package/cjs/src/tools/search.js +147 -0
  20. package/cjs/src/tools/search.js.map +1 -0
  21. package/cjs/src/version.js +142 -0
  22. package/cjs/src/version.js.map +1 -0
  23. package/esm/README.md +247 -0
  24. package/esm/bin/attrove-mcp.js +69 -0
  25. package/esm/package.json +69 -0
  26. package/esm/src/__mocks__/version.js +12 -0
  27. package/esm/src/__mocks__/version.js.map +1 -0
  28. package/esm/src/constants.js +14 -0
  29. package/esm/src/constants.js.map +1 -0
  30. package/esm/src/index.js +32 -0
  31. package/esm/src/index.js.map +1 -0
  32. package/esm/src/server.js +241 -0
  33. package/esm/src/server.js.map +1 -0
  34. package/esm/src/tools/index.js +19 -0
  35. package/esm/src/tools/index.js.map +1 -0
  36. package/esm/src/tools/integrations.js +46 -0
  37. package/esm/src/tools/integrations.js.map +1 -0
  38. package/esm/src/tools/query.js +66 -0
  39. package/esm/src/tools/query.js.map +1 -0
  40. package/esm/src/tools/search.js +143 -0
  41. package/esm/src/tools/search.js.map +1 -0
  42. package/esm/src/version.js +137 -0
  43. package/esm/src/version.js.map +1 -0
  44. package/package.json +13 -11
  45. package/types/src/__mocks__/version.d.ts +7 -0
  46. package/types/src/constants.d.ts +13 -0
  47. package/types/src/index.d.ts +32 -0
  48. package/types/src/server.d.ts +38 -0
  49. package/types/src/tools/index.d.ts +80 -0
  50. package/types/src/tools/integrations.d.ts +22 -0
  51. package/types/src/tools/query.d.ts +47 -0
  52. package/types/src/tools/search.d.ts +57 -0
  53. package/types/src/version.d.ts +23 -0
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ /**
3
+ * MCP Server Version Utilities
4
+ *
5
+ * Reads the version from package.json at runtime to ensure the reported
6
+ * version always matches the published package version.
7
+ *
8
+ * Uses a cross-platform approach that works in both ESM and CJS environments
9
+ * by parsing Error stack traces to determine the current file location.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.resetVersionCache = exports.getVersion = void 0;
13
+ const fs_1 = require("fs");
14
+ const path_1 = require("path");
15
+ const url_1 = require("url");
16
+ /**
17
+ * Fallback version used when package.json cannot be read.
18
+ * This should only happen in unusual development environments.
19
+ */
20
+ const FALLBACK_VERSION = '0.0.0-unknown';
21
+ /**
22
+ * Cached version string to avoid repeated file reads.
23
+ */
24
+ let cachedVersion;
25
+ /**
26
+ * Get the directory of the current file using Error stack trace parsing.
27
+ * Works in both ESM and CJS environments without relying on __dirname or import.meta.url.
28
+ */
29
+ function getCurrentDirectory() {
30
+ const err = new Error();
31
+ const stack = err.stack || '';
32
+ // Stack trace line patterns:
33
+ // Node CJS: " at Function.<anonymous> (/path/to/file.js:10:15)"
34
+ // Node ESM: " at file:///path/to/file.js:10:15"
35
+ // Also handles: " at /path/to/file.js:10:15"
36
+ const lines = stack.split('\n');
37
+ for (const line of lines) {
38
+ // Skip the Error message line and this function's frame
39
+ if (!line.includes('getCurrentDirectory') && !line.startsWith('Error')) {
40
+ // Match file:// URLs (ESM)
41
+ const fileUrlMatch = line.match(/file:\/\/([^:]+):\d+:\d+/);
42
+ if (fileUrlMatch) {
43
+ try {
44
+ const filePath = (0, url_1.fileURLToPath)(`file://${fileUrlMatch[1]}`);
45
+ return (0, path_1.dirname)(filePath);
46
+ }
47
+ catch {
48
+ // Continue to next pattern
49
+ }
50
+ }
51
+ // Match parenthesized paths: "at Something (/path/to/file.js:10:15)"
52
+ const parenMatch = line.match(/\(([^)]+):\d+:\d+\)/);
53
+ if (parenMatch && !parenMatch[1].startsWith('node:')) {
54
+ return (0, path_1.dirname)(parenMatch[1]);
55
+ }
56
+ // Match bare paths: "at /path/to/file.js:10:15"
57
+ const bareMatch = line.match(/at\s+([^:]+):\d+:\d+/);
58
+ if (bareMatch && !bareMatch[1].startsWith('node:') && !bareMatch[1].includes('(')) {
59
+ return (0, path_1.dirname)(bareMatch[1].trim());
60
+ }
61
+ }
62
+ }
63
+ return null;
64
+ }
65
+ /**
66
+ * Search for package.json with the correct package name starting from a directory.
67
+ */
68
+ function findPackageJson(startDir, packageName) {
69
+ let dir = startDir;
70
+ const visited = new Set();
71
+ while (dir && !visited.has(dir)) {
72
+ visited.add(dir);
73
+ const pkgPath = (0, path_1.join)(dir, 'package.json');
74
+ if ((0, fs_1.existsSync)(pkgPath)) {
75
+ try {
76
+ const pkg = JSON.parse((0, fs_1.readFileSync)(pkgPath, 'utf-8'));
77
+ if (pkg.name === packageName && pkg.version) {
78
+ return pkg.version;
79
+ }
80
+ }
81
+ catch {
82
+ // Continue searching
83
+ }
84
+ }
85
+ const parent = (0, path_1.dirname)(dir);
86
+ if (parent === dir)
87
+ break;
88
+ dir = parent;
89
+ }
90
+ return null;
91
+ }
92
+ /**
93
+ * Get the MCP server version from package.json.
94
+ *
95
+ * This function reads the version at runtime from the package.json file,
96
+ * ensuring the MCP server always reports the correct published version
97
+ * to clients.
98
+ *
99
+ * The version is cached after the first read for performance.
100
+ */
101
+ function getVersion() {
102
+ if (cachedVersion !== undefined) {
103
+ return cachedVersion;
104
+ }
105
+ const packageName = '@attrove/mcp';
106
+ // Try to find package.json starting from the current file's directory
107
+ const currentDir = getCurrentDirectory();
108
+ if (currentDir) {
109
+ const version = findPackageJson(currentDir, packageName);
110
+ if (version) {
111
+ cachedVersion = version;
112
+ return version;
113
+ }
114
+ }
115
+ // Fallback: search from common locations relative to process.cwd()
116
+ const fallbackPaths = [
117
+ (0, path_1.resolve)(process.cwd(), 'packages/mcp'),
118
+ (0, path_1.resolve)(process.cwd(), 'node_modules/@attrove/mcp'),
119
+ process.cwd(),
120
+ ];
121
+ for (const searchPath of fallbackPaths) {
122
+ if ((0, fs_1.existsSync)(searchPath)) {
123
+ const version = findPackageJson(searchPath, packageName);
124
+ if (version) {
125
+ cachedVersion = version;
126
+ return version;
127
+ }
128
+ }
129
+ }
130
+ // If we can't find package.json, use the fallback
131
+ cachedVersion = FALLBACK_VERSION;
132
+ return FALLBACK_VERSION;
133
+ }
134
+ exports.getVersion = getVersion;
135
+ /**
136
+ * Reset the cached version. Primarily for testing purposes.
137
+ */
138
+ function resetVersionCache() {
139
+ cachedVersion = undefined;
140
+ }
141
+ exports.resetVersionCache = resetVersionCache;
142
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../../packages/mcp/src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,2BAA8C;AAC9C,+BAA8C;AAC9C,6BAAoC;AAEpC;;;GAGG;AACH,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEzC;;GAEG;AACH,IAAI,aAAiC,CAAC;AAEtC;;;GAGG;AACH,SAAS,mBAAmB;IAC1B,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;IACxB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;IAE9B,6BAA6B;IAC7B,mEAAmE;IACnE,mDAAmD;IACnD,gDAAgD;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;I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AO,CAAC;QACjB,CAAC;IACH,CAAC;IAED,mEAAmE;IACnE,MAAM,aAAa,GAAG;QACpB,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;QACtC,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,2BAA2B,CAAC;QACnD,OAAO,CAAC,GAAG,EAAE;KACd,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,aAAa,EAAE,CAAC;QACvC,IAAI,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,eAAe,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;YACzD,IAAI,OAAO,EAAE,CAAC;gBACZ,aAAa,GAAG,OAAO,CAAC;gBACxB,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAED,kDAAkD;IAClD,aAAa,GAAG,gBAAgB,CAAC;IACjC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AArCD,gCAqCC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,aAAa,GAAG,SAAS,CAAC;AAC5B,CAAC;AAFD,8CAEC"}
package/esm/README.md ADDED
@@ -0,0 +1,247 @@
1
+ # @attrove/mcp
2
+
3
+ MCP (Model Context Protocol) server for Attrove. Enables AI assistants like Claude and Cursor to access your users' unified context from Gmail, Slack, Google Calendar, and more.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @attrove/mcp
9
+ # or
10
+ yarn add @attrove/mcp
11
+ # or
12
+ pnpm add @attrove/mcp
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ### Claude Desktop
18
+
19
+ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
20
+
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "attrove": {
25
+ "command": "npx",
26
+ "args": ["@attrove/mcp"],
27
+ "env": {
28
+ "ATTROVE_API_KEY": "sk_...",
29
+ "ATTROVE_USER_ID": "user-uuid"
30
+ }
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ ### Cursor
37
+
38
+ 1. Open Cursor Settings (`Cmd+,` on macOS, `Ctrl+,` on Windows/Linux)
39
+ 2. Search for "MCP" or navigate to **Features > MCP Servers**
40
+ 3. Click "Edit in settings.json" or add directly:
41
+
42
+ ```json
43
+ {
44
+ "mcpServers": {
45
+ "attrove": {
46
+ "command": "npx",
47
+ "args": ["@attrove/mcp"],
48
+ "env": {
49
+ "ATTROVE_API_KEY": "sk_...",
50
+ "ATTROVE_USER_ID": "user-uuid"
51
+ }
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ 4. Restart Cursor for changes to take effect
58
+ 5. In the chat, you can now ask questions about your connected integrations
59
+
60
+ ### Claude Code (Terminal)
61
+
62
+ If using Claude Code in the terminal, the MCP server is configured via environment variables:
63
+
64
+ ```bash
65
+ export ATTROVE_API_KEY="sk_..."
66
+ export ATTROVE_USER_ID="user-uuid"
67
+ ```
68
+
69
+ ### Direct CLI Usage
70
+
71
+ ```bash
72
+ ATTROVE_API_KEY=sk_... ATTROVE_USER_ID=user-uuid npx @attrove/mcp
73
+ ```
74
+
75
+ ## Common Use Cases
76
+
77
+ Once connected, you can ask your AI assistant natural language questions. Here are some examples:
78
+
79
+ **Meeting prep:**
80
+ > "What context do I need for my 2pm meeting with the marketing team?"
81
+
82
+ **Email follow-ups:**
83
+ > "Are there any emails from last week that I haven't responded to?"
84
+
85
+ **Project status:**
86
+ > "What's the latest on the Q4 roadmap discussions?"
87
+
88
+ **People search:**
89
+ > "What has John from Acme Corp been asking about recently?"
90
+
91
+ **Historical context:**
92
+ > "Find the thread where we discussed the pricing changes last month"
93
+
94
+ ## Available Tools
95
+
96
+ ### `attrove_query`
97
+
98
+ Ask questions about the user's communications and get AI-generated answers.
99
+
100
+ **Parameters:**
101
+ - `query` (required): The question to ask
102
+ - `integration_ids` (optional): Filter to specific integration IDs (UUIDs, e.g., `["550e8400-e29b-41d4-a716-446655440000"]`)
103
+ - `include_sources` (optional): Include source snippets
104
+
105
+ **Example prompts:**
106
+ - "What did Sarah say about the Q4 budget?"
107
+ - "Summarize my meeting with the engineering team"
108
+ - "What are the action items from yesterday's standup?"
109
+ - "When is my next meeting with the product team?"
110
+ - "What context do I need before my 3pm call?"
111
+
112
+ ### `attrove_search`
113
+
114
+ Search for specific messages or conversations.
115
+
116
+ **Parameters:**
117
+ - `query` (required): The search query
118
+ - `after_date` (optional): Only messages after this date (ISO 8601)
119
+ - `before_date` (optional): Only messages before this date
120
+ - `sender_domains` (optional): Filter by sender domains
121
+ - `include_body_text` (optional): Include message content (default: true)
122
+
123
+ **Example prompts:**
124
+ - "Find all emails about the product launch"
125
+ - "Show me conversations with the marketing team"
126
+ - "Search for messages mentioning the deadline extension"
127
+ - "Find discussions with acme.com from last month"
128
+
129
+ ### `attrove_integrations`
130
+
131
+ List the user's connected integrations.
132
+
133
+ **Parameters:** None
134
+
135
+ **Example prompts:**
136
+ - "What services are connected?"
137
+ - "Show me my integrations"
138
+
139
+ ## Environment Variables
140
+
141
+ | Variable | Required | Description |
142
+ |----------|----------|-------------|
143
+ | `ATTROVE_API_KEY` | Yes | Your Attrove API key (`sk_...`) |
144
+ | `ATTROVE_USER_ID` | Yes | User ID to scope API calls |
145
+ | `ATTROVE_BASE_URL` | No | Custom API base URL |
146
+ | `ATTROVE_DEBUG` | No | Set to `true` for verbose error logging |
147
+
148
+ ## Programmatic Usage
149
+
150
+ You can also use the server programmatically:
151
+
152
+ ```typescript
153
+ import { createServer, startServer } from '@attrove/mcp';
154
+
155
+ // Create a server instance
156
+ const server = createServer({
157
+ apiKey: 'sk_...',
158
+ userId: 'user-uuid'
159
+ });
160
+
161
+ // Or start directly with stdio transport
162
+ await startServer({
163
+ apiKey: 'sk_...',
164
+ userId: 'user-uuid'
165
+ });
166
+ ```
167
+
168
+ ## Getting API Credentials
169
+
170
+ 1. Sign up at [attrove.com](https://attrove.com)
171
+ 2. Create an organization in the dashboard
172
+ 3. Generate an API key (`sk_...`)
173
+ 4. Provision a user to get a user ID
174
+
175
+ ```typescript
176
+ import { Attrove } from '@attrove/sdk';
177
+
178
+ const admin = Attrove.admin({
179
+ clientId: 'your-client-id',
180
+ clientSecret: 'your-client-secret'
181
+ });
182
+
183
+ // Create a user
184
+ const { id, apiKey } = await admin.users.create({
185
+ email: 'user@example.com'
186
+ });
187
+
188
+ // Use `apiKey` as ATTROVE_API_KEY and `id` as ATTROVE_USER_ID
189
+ ```
190
+
191
+ ## Troubleshooting
192
+
193
+ ### "ATTROVE_API_KEY environment variable is required"
194
+
195
+ Make sure you've set the environment variables correctly in your MCP configuration.
196
+
197
+ ### Tools not showing up
198
+
199
+ 1. Restart Claude/Cursor after configuration changes
200
+ 2. Check the MCP server logs for errors
201
+ 3. Verify your API key is valid
202
+
203
+ ### Debugging errors
204
+
205
+ Set `ATTROVE_DEBUG=true` to enable verbose error logging with stack traces:
206
+
207
+ ```json
208
+ {
209
+ "mcpServers": {
210
+ "attrove": {
211
+ "command": "npx",
212
+ "args": ["@attrove/mcp"],
213
+ "env": {
214
+ "ATTROVE_API_KEY": "sk_...",
215
+ "ATTROVE_USER_ID": "user-uuid",
216
+ "ATTROVE_DEBUG": "true"
217
+ }
218
+ }
219
+ }
220
+ }
221
+ ```
222
+
223
+ ### Rate limiting
224
+
225
+ The Attrove API has rate limits. If you're making many requests, you may need to wait before trying again.
226
+
227
+ ## Requirements
228
+
229
+ - Node.js 18.0.0 or later
230
+
231
+ ## AI-Friendly Documentation
232
+
233
+ For AI assistants and code generation tools, Attrove provides machine-readable documentation:
234
+
235
+ - **llms.txt**: `https://attrove.com/llms.txt` - Condensed API reference for LLMs
236
+ - **Quickstart**: `https://github.com/attrove/quickstart` - Example code with CLAUDE.md context
237
+
238
+ ## Links
239
+
240
+ - [Documentation](https://docs.attrove.com)
241
+ - [API Reference](https://docs.attrove.com/api)
242
+ - [TypeScript SDK](https://www.npmjs.com/package/@attrove/sdk)
243
+ - [Quickstart Examples](https://github.com/attrove/quickstart)
244
+
245
+ ## License
246
+
247
+ MIT
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Attrove MCP Server CLI
5
+ *
6
+ * Starts the MCP server for use with Claude, Cursor, or other MCP-compatible clients.
7
+ *
8
+ * Required environment variables:
9
+ * - ATTROVE_API_KEY: Your Attrove API key (sk_...)
10
+ * - ATTROVE_USER_ID: The user ID to scope API calls
11
+ *
12
+ * Optional environment variables:
13
+ * - ATTROVE_BASE_URL: Custom API base URL (defaults to https://api.attrove.com)
14
+ * - ATTROVE_DEBUG: Set to "true" to enable debug logging
15
+ *
16
+ * Usage:
17
+ * ATTROVE_API_KEY=sk_... ATTROVE_USER_ID=... npx @attrove/mcp
18
+ *
19
+ * Claude Desktop configuration:
20
+ * {
21
+ * "mcpServers": {
22
+ * "attrove": {
23
+ * "command": "npx",
24
+ * "args": ["@attrove/mcp"],
25
+ * "env": {
26
+ * "ATTROVE_API_KEY": "sk_...",
27
+ * "ATTROVE_USER_ID": "..."
28
+ * }
29
+ * }
30
+ * }
31
+ * }
32
+ */
33
+
34
+ const isDebug = process.env.ATTROVE_DEBUG === 'true' || process.env.DEBUG === 'true';
35
+
36
+ async function main() {
37
+ try {
38
+ // Import the server module
39
+ const { startServer, getConfigFromEnv } = await import('../esm/index.js');
40
+
41
+ // Get configuration from environment
42
+ const config = getConfigFromEnv();
43
+
44
+ // Start the server
45
+ await startServer(config);
46
+ } catch (error) {
47
+ // Always show the error message
48
+ console.error('Failed to start Attrove MCP server:', error.message);
49
+
50
+ // Show stack trace in debug mode for easier troubleshooting
51
+ if (isDebug && error.stack) {
52
+ console.error('\nStack trace:');
53
+ console.error(error.stack);
54
+ }
55
+
56
+ // Show additional context for common errors
57
+ if (error.message.includes('ATTROVE_API_KEY')) {
58
+ console.error('\nHint: Set the ATTROVE_API_KEY environment variable to your API key (sk_...)');
59
+ } else if (error.message.includes('ATTROVE_USER_ID')) {
60
+ console.error('\nHint: Set the ATTROVE_USER_ID environment variable to the user ID (UUID)');
61
+ } else if (error.message.includes('Cannot find module')) {
62
+ console.error('\nHint: Try running "npm install" or "npm rebuild" to reinstall dependencies');
63
+ }
64
+
65
+ process.exit(1);
66
+ }
67
+ }
68
+
69
+ main();
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@attrove/mcp",
3
+ "version": "0.1.4",
4
+ "description": "MCP server for Attrove - AI-powered context retrieval for Claude and Cursor",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.js",
7
+ "types": "./dist/types/index.d.ts",
8
+ "bin": {
9
+ "attrove-mcp": "./bin/attrove-mcp.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": {
14
+ "types": "./dist/types/index.d.ts",
15
+ "default": "./dist/esm/index.js"
16
+ },
17
+ "require": {
18
+ "types": "./dist/types/index.d.ts",
19
+ "default": "./dist/cjs/index.js"
20
+ }
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "bin",
26
+ "README.md"
27
+ ],
28
+ "sideEffects": false,
29
+ "keywords": [
30
+ "attrove",
31
+ "mcp",
32
+ "model-context-protocol",
33
+ "claude",
34
+ "cursor",
35
+ "ai",
36
+ "rag",
37
+ "llm"
38
+ ],
39
+ "author": "Attrove <support@attrove.com>",
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/attrove/attrove-js.git",
44
+ "directory": "packages/mcp"
45
+ },
46
+ "homepage": "https://attrove.com/docs/mcp",
47
+ "bugs": {
48
+ "url": "https://github.com/attrove/attrove-js/issues"
49
+ },
50
+ "engines": {
51
+ "node": ">=18.0.0"
52
+ },
53
+ "scripts": {
54
+ "build": "nx build mcp",
55
+ "test": "nx test mcp"
56
+ },
57
+ "dependencies": {
58
+ "@modelcontextprotocol/sdk": "^1.0.0",
59
+ "@attrove/sdk": "*"
60
+ },
61
+ "devDependencies": {
62
+ "@types/node": "^20.0.0",
63
+ "typescript": "~5.7.0"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "type": "module"
69
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Mock version module for Jest tests.
3
+ *
4
+ * This avoids the import.meta.url ESM issue when running tests with ts-jest.
5
+ */
6
+ export function getVersion() {
7
+ return '1.0.0-test';
8
+ }
9
+ export function resetVersionCache() {
10
+ // No-op in mock
11
+ }
12
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../../../packages/mcp/src/__mocks__/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,UAAU;IACxB,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,gBAAgB;AAClB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * MCP Constants
3
+ *
4
+ * Centralized constants used across the MCP server. Consolidating these ensures
5
+ * consistency and makes maintenance easier.
6
+ */
7
+ /**
8
+ * Maximum length for message body preview text in search results.
9
+ *
10
+ * When displaying search results, message bodies longer than this value
11
+ * will be truncated with an ellipsis to keep output manageable.
12
+ */
13
+ export const MAX_BODY_PREVIEW_LENGTH = 200;
14
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/mcp/src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @attrove/mcp
3
+ *
4
+ * MCP server for Attrove - enables AI assistants like Claude and Cursor
5
+ * to access user context through the Attrove API.
6
+ *
7
+ * @example
8
+ * ```bash
9
+ * # Run via npx
10
+ * ATTROVE_API_KEY=sk_... ATTROVE_USER_ID=... npx @attrove/mcp
11
+ *
12
+ * # Configure in Claude Desktop
13
+ * {
14
+ * "mcpServers": {
15
+ * "attrove": {
16
+ * "command": "npx",
17
+ * "args": ["@attrove/mcp"],
18
+ * "env": {
19
+ * "ATTROVE_API_KEY": "sk_...",
20
+ * "ATTROVE_USER_ID": "..."
21
+ * }
22
+ * }
23
+ * }
24
+ * }
25
+ * ```
26
+ *
27
+ * @packageDocumentation
28
+ */
29
+ export { createServer, startServer, getConfigFromEnv } from './server';
30
+ export { allToolDefinitions, queryToolDefinition, searchToolDefinition, integrationsToolDefinition, } from './tools';
31
+ export { getVersion } from './version';
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/mcp/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGvE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}