salesflare-mcp-server 1.0.0
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/API.md +691 -0
- package/CHANGELOG.md +49 -0
- package/CLAUDE.md +117 -0
- package/CONTRIBUTING.md +399 -0
- package/FIX_PLAN.md +70 -0
- package/INSPECTOR.md +191 -0
- package/LICENSE +21 -0
- package/PUBLISH.md +73 -0
- package/README.md +383 -0
- package/dist/auth/api-key-auth.d.ts +75 -0
- package/dist/auth/api-key-auth.d.ts.map +1 -0
- package/dist/auth/api-key-auth.js +103 -0
- package/dist/auth/oauth-auth.d.ts +81 -0
- package/dist/auth/oauth-auth.d.ts.map +1 -0
- package/dist/auth/oauth-auth.js +123 -0
- package/dist/auth/token-manager.d.ts +105 -0
- package/dist/auth/token-manager.d.ts.map +1 -0
- package/dist/auth/token-manager.js +87 -0
- package/dist/client/salesflare-client.d.ts +219 -0
- package/dist/client/salesflare-client.d.ts.map +1 -0
- package/dist/client/salesflare-client.js +484 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/server.d.ts +39 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +140 -0
- package/dist/tools/companies.d.ts +45 -0
- package/dist/tools/companies.d.ts.map +1 -0
- package/dist/tools/companies.js +392 -0
- package/dist/tools/contacts.d.ts +45 -0
- package/dist/tools/contacts.d.ts.map +1 -0
- package/dist/tools/contacts.js +290 -0
- package/dist/tools/deals.d.ts +46 -0
- package/dist/tools/deals.d.ts.map +1 -0
- package/dist/tools/deals.js +442 -0
- package/dist/tools/pipeline.d.ts +43 -0
- package/dist/tools/pipeline.d.ts.map +1 -0
- package/dist/tools/pipeline.js +328 -0
- package/dist/tools/tasks.d.ts +44 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +406 -0
- package/dist/transport/http-transport.d.ts +36 -0
- package/dist/transport/http-transport.d.ts.map +1 -0
- package/dist/transport/http-transport.js +173 -0
- package/dist/transport/stdio-transport.d.ts +37 -0
- package/dist/transport/stdio-transport.d.ts.map +1 -0
- package/dist/transport/stdio-transport.js +129 -0
- package/dist/types/company.d.ts +223 -0
- package/dist/types/company.d.ts.map +1 -0
- package/dist/types/company.js +8 -0
- package/dist/types/contact.d.ts +166 -0
- package/dist/types/contact.d.ts.map +1 -0
- package/dist/types/contact.js +8 -0
- package/dist/types/deal.d.ts +203 -0
- package/dist/types/deal.d.ts.map +1 -0
- package/dist/types/deal.js +8 -0
- package/dist/types/pipeline.d.ts +116 -0
- package/dist/types/pipeline.d.ts.map +1 -0
- package/dist/types/pipeline.js +8 -0
- package/dist/types/task.d.ts +154 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +8 -0
- package/dist/utils/errors.d.ts +128 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +205 -0
- package/dist/utils/validation.d.ts +354 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +716 -0
- package/package.json +49 -0
- package/test-tasks-debug.js +21 -0
- package/test-tasks-params.js +52 -0
- package/test-tools.js +171 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-06-02
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial release of Salesflare MCP Server
|
|
13
|
+
- API key authentication support
|
|
14
|
+
- Stdio and HTTP Streamable transports
|
|
15
|
+
- Contact management (list, create, update, delete)
|
|
16
|
+
- Company management (list, create, update, delete) with contact unlinking
|
|
17
|
+
- Deal management (list, create, update, delete, move_stage)
|
|
18
|
+
- Task management (list, create, update) with overdue detection
|
|
19
|
+
- Pipeline operations (list stages, overview with statistics)
|
|
20
|
+
- Comprehensive test suite with 300+ unit tests
|
|
21
|
+
- MCP Inspector compatibility
|
|
22
|
+
- Full API documentation (API.md)
|
|
23
|
+
- Contributing guide (CONTRIBUTING.md)
|
|
24
|
+
- MCP Inspector testing guide (INSPECTOR.md)
|
|
25
|
+
|
|
26
|
+
### Technical
|
|
27
|
+
|
|
28
|
+
- TypeScript with strict mode
|
|
29
|
+
- Zod for schema validation
|
|
30
|
+
- Axios for HTTP client with retry logic
|
|
31
|
+
- Express for HTTP transport
|
|
32
|
+
- Jest for testing
|
|
33
|
+
- 80%+ code coverage for core modules
|
|
34
|
+
|
|
35
|
+
### Notes
|
|
36
|
+
|
|
37
|
+
- Requires Node.js >= 18.0.0
|
|
38
|
+
- Requires Salesflare API key
|
|
39
|
+
- OAuth 2.0 planned for Phase 2
|
|
40
|
+
|
|
41
|
+
## [Unreleased]
|
|
42
|
+
|
|
43
|
+
### Planned
|
|
44
|
+
|
|
45
|
+
- OAuth 2.0 authentication
|
|
46
|
+
- Webhook support
|
|
47
|
+
- Bulk operations
|
|
48
|
+
- Advanced filtering
|
|
49
|
+
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# CLAUDE.md — Salesflare MCP Server
|
|
2
|
+
|
|
3
|
+
This file contains GSD workflow guidance and project context for Claude/OpenCode when working on this project.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
**Salesflare MCP Server** — A Model Context Protocol server enabling LLMs to interact with Salesflare CRM via natural language.
|
|
8
|
+
|
|
9
|
+
- **Language:** TypeScript
|
|
10
|
+
- **Transport:** stdio + HTTP Streamable
|
|
11
|
+
- **Auth:** API Key + OAuth 2.0
|
|
12
|
+
- **Status:** Phase 1 (Infrastructure & Auth)
|
|
13
|
+
|
|
14
|
+
## Quick Links
|
|
15
|
+
|
|
16
|
+
- `.planning/PROJECT.md` — Project context, requirements, decisions
|
|
17
|
+
- `.planning/REQUIREMENTS.md` — Detailed requirements with traceability
|
|
18
|
+
- `.planning/ROADMAP.md` — 6-phase execution plan
|
|
19
|
+
- `.planning/STATE.md` — Current status and blockers
|
|
20
|
+
- `.planning/config.json` — Workflow settings
|
|
21
|
+
|
|
22
|
+
## GSD Commands Available
|
|
23
|
+
|
|
24
|
+
- `/gsd-discuss-phase [N]` — Gather context before planning
|
|
25
|
+
- `/gsd-plan-phase [N]` — Create detailed plan for phase
|
|
26
|
+
- `/gsd-execute-phase [N]` — Execute phase plan
|
|
27
|
+
- `/gsd-verify-work [N]` — Verify phase completion
|
|
28
|
+
- `/gsd-progress` — Check overall project status
|
|
29
|
+
|
|
30
|
+
## Development Guidelines
|
|
31
|
+
|
|
32
|
+
### TypeScript Standards
|
|
33
|
+
- Strict mode enabled
|
|
34
|
+
- Use Zod for all input validation
|
|
35
|
+
- Async/await for all async operations
|
|
36
|
+
- Proper error handling with actionable messages
|
|
37
|
+
|
|
38
|
+
### MCP Patterns
|
|
39
|
+
- Tool naming: `salesflare_[entity]_[action]` (e.g., `salesflare_contacts_list`)
|
|
40
|
+
- Input schemas: Use Zod with descriptive field names
|
|
41
|
+
- Output: Return both text and structured data where applicable
|
|
42
|
+
- Annotations: Mark readOnly/destructive/idempotent hints
|
|
43
|
+
|
|
44
|
+
### API Client Patterns
|
|
45
|
+
- Base URL: `https://api.salesflare.com`
|
|
46
|
+
- Headers: `Authorization: Bearer {token}`
|
|
47
|
+
- Rate limiting: Implement exponential backoff
|
|
48
|
+
- Error handling: Map API errors to MCP error responses
|
|
49
|
+
|
|
50
|
+
### Testing
|
|
51
|
+
- MCP Inspector: `npx @modelcontextprotocol/inspector`
|
|
52
|
+
- Unit tests: Jest with mocked API
|
|
53
|
+
- Integration tests: Live API with test account
|
|
54
|
+
|
|
55
|
+
## Architecture
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
src/
|
|
59
|
+
├── index.ts # Entry point, transport setup
|
|
60
|
+
├── server.ts # MCP server configuration
|
|
61
|
+
├── client/
|
|
62
|
+
│ └── salesflare.ts # Salesflare API client
|
|
63
|
+
├── tools/
|
|
64
|
+
│ ├── contacts.ts # Contact tools
|
|
65
|
+
│ ├── companies.ts # Company tools
|
|
66
|
+
│ ├── deals.ts # Deal tools
|
|
67
|
+
│ ├── tasks.ts # Task tools
|
|
68
|
+
│ └── pipeline.ts # Pipeline tools
|
|
69
|
+
├── auth/
|
|
70
|
+
│ ├── api-key.ts # API key auth
|
|
71
|
+
│ └── oauth.ts # OAuth 2.0 flow
|
|
72
|
+
└── utils/
|
|
73
|
+
├── errors.ts # Error handling
|
|
74
|
+
└── pagination.ts # Pagination helpers
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Environment Variables
|
|
78
|
+
|
|
79
|
+
```env
|
|
80
|
+
SALESFLARE_API_KEY= # For API key auth
|
|
81
|
+
SALESFLARE_CLIENT_ID= # For OAuth
|
|
82
|
+
SALESFLARE_CLIENT_SECRET= # For OAuth
|
|
83
|
+
SALESFLARE_REDIRECT_URI= # For OAuth
|
|
84
|
+
TRANSPORT=stdio|http # Transport mode
|
|
85
|
+
PORT=3000 # HTTP port (if http transport)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Building
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install
|
|
92
|
+
npm run build
|
|
93
|
+
npm run test
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Running
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# stdio mode (for MCP Inspector)
|
|
100
|
+
npm start
|
|
101
|
+
|
|
102
|
+
# HTTP mode
|
|
103
|
+
TRANSPORT=http npm start
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Dependencies
|
|
107
|
+
|
|
108
|
+
- `@modelcontextprotocol/server` — MCP SDK
|
|
109
|
+
- `zod` — Schema validation
|
|
110
|
+
- `axios` — HTTP client
|
|
111
|
+
- `typescript` — Type checking
|
|
112
|
+
- `jest` — Testing
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
*Last updated: 2025-05-15*
|
|
117
|
+
*GSD Version: 1.0*
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
# Contributing to Salesflare MCP Server
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing! This guide will help you get started with development.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- **Node.js** >= 18.0.0
|
|
10
|
+
- **npm** >= 9.0.0
|
|
11
|
+
- **Git**
|
|
12
|
+
|
|
13
|
+
### Clone and Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git clone https://github.com/salesflare/mcp-server.git
|
|
17
|
+
cd mcp-server
|
|
18
|
+
npm install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Configure Environment
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Copy environment template
|
|
25
|
+
cp .env.example .env
|
|
26
|
+
|
|
27
|
+
# Edit .env with your credentials
|
|
28
|
+
SALESFLARE_API_KEY=your_api_key_here
|
|
29
|
+
TRANSPORT=stdio
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Get your API key from: https://app.salesflare.com/settings/api
|
|
33
|
+
|
|
34
|
+
### Build the Project
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Build once
|
|
38
|
+
npm run build
|
|
39
|
+
|
|
40
|
+
# Watch mode (rebuilds on changes)
|
|
41
|
+
npm run dev
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Verify Setup
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Run tests
|
|
48
|
+
npm test
|
|
49
|
+
|
|
50
|
+
# Start the server
|
|
51
|
+
npm start
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Project Structure
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
src/
|
|
58
|
+
├── index.ts # Entry point with transport setup
|
|
59
|
+
├── server.ts # MCP server configuration
|
|
60
|
+
├── auth/
|
|
61
|
+
│ ├── api-key-auth.ts # API key authentication
|
|
62
|
+
│ ├── oauth-auth.ts # OAuth 2.0 (Phase 2)
|
|
63
|
+
│ └── token-manager.ts # Token lifecycle management
|
|
64
|
+
├── client/
|
|
65
|
+
│ └── salesflare-client.ts # HTTP client with retry logic
|
|
66
|
+
├── transport/
|
|
67
|
+
│ ├── stdio-transport.ts # Stdio transport
|
|
68
|
+
│ └── http-transport.ts # HTTP transport
|
|
69
|
+
├── tools/
|
|
70
|
+
│ ├── contacts.ts # Contact CRUD tools
|
|
71
|
+
│ ├── companies.ts # Company CRUD tools
|
|
72
|
+
│ ├── deals.ts # Deal management tools
|
|
73
|
+
│ ├── tasks.ts # Task management tools
|
|
74
|
+
│ └── pipeline.ts # Pipeline tools
|
|
75
|
+
├── types/
|
|
76
|
+
│ ├── contact.ts # Contact types
|
|
77
|
+
│ ├── company.ts # Company types
|
|
78
|
+
│ ├── deal.ts # Deal types
|
|
79
|
+
│ ├── task.ts # Task types
|
|
80
|
+
│ └── pipeline.ts # Pipeline types
|
|
81
|
+
└── utils/
|
|
82
|
+
├── errors.ts # Error handling utilities
|
|
83
|
+
└── validation.ts # Zod validation schemas
|
|
84
|
+
|
|
85
|
+
tests/
|
|
86
|
+
├── unit/ # Unit tests
|
|
87
|
+
│ ├── contacts-*.test.ts
|
|
88
|
+
│ ├── companies-*.test.ts
|
|
89
|
+
│ ├── deals-*.test.ts
|
|
90
|
+
│ ├── tasks-*.test.ts
|
|
91
|
+
│ ├── pipeline-*.test.ts
|
|
92
|
+
│ └── validation.test.ts
|
|
93
|
+
└── integration/ # Integration tests
|
|
94
|
+
└── server.test.ts
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Running Tests
|
|
98
|
+
|
|
99
|
+
### All Tests
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm test
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### With Coverage
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm test -- --coverage
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Coverage reports are generated in `coverage/` directory.
|
|
112
|
+
|
|
113
|
+
### Watch Mode
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm test -- --watch
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Specific Test File
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm test -- contacts-list.test.ts
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Integration Tests
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Requires SALESFLARE_API_KEY to be set
|
|
129
|
+
npm run test:integration
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Testing with MCP Inspector
|
|
133
|
+
|
|
134
|
+
The MCP Inspector is the best way to test tool behavior:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Start with Inspector
|
|
138
|
+
npm run inspector
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
This opens a web interface where you can:
|
|
142
|
+
- Browse all available tools
|
|
143
|
+
- Test tool inputs
|
|
144
|
+
- View responses
|
|
145
|
+
- Debug errors
|
|
146
|
+
|
|
147
|
+
See [INSPECTOR.md](INSPECTOR.md) for detailed testing scenarios.
|
|
148
|
+
|
|
149
|
+
## Code Style
|
|
150
|
+
|
|
151
|
+
### TypeScript
|
|
152
|
+
|
|
153
|
+
- **Strict mode** enabled
|
|
154
|
+
- Use **explicit types** where inference is unclear
|
|
155
|
+
- Use **interface** for object shapes, **type** for unions/aliases
|
|
156
|
+
- Prefix private methods with `_`
|
|
157
|
+
|
|
158
|
+
### Error Handling
|
|
159
|
+
|
|
160
|
+
All errors must use the `SalesflareError` class:
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { SalesflareError, ErrorCode } from '../utils/errors.js';
|
|
164
|
+
|
|
165
|
+
// Validation errors
|
|
166
|
+
throw new SalesflareError(
|
|
167
|
+
'Email is required',
|
|
168
|
+
ErrorCode.VALIDATION_ERROR,
|
|
169
|
+
400,
|
|
170
|
+
{ field: 'email' },
|
|
171
|
+
false
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
// API errors (retryable)
|
|
175
|
+
throw new SalesflareError(
|
|
176
|
+
'Rate limit exceeded',
|
|
177
|
+
ErrorCode.RATE_LIMIT,
|
|
178
|
+
429,
|
|
179
|
+
{},
|
|
180
|
+
true
|
|
181
|
+
);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Validation
|
|
185
|
+
|
|
186
|
+
Use Zod for all input validation:
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { z } from 'zod';
|
|
190
|
+
|
|
191
|
+
const createContactSchema = z.object({
|
|
192
|
+
email: z.string().email(),
|
|
193
|
+
name: z.string().optional(),
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Validate
|
|
197
|
+
const result = createContactSchema.safeParse(input);
|
|
198
|
+
if (!result.success) {
|
|
199
|
+
// Handle validation errors
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Async/Await
|
|
204
|
+
|
|
205
|
+
Use async/await for all asynchronous operations:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// Good
|
|
209
|
+
async function fetchContacts(): Promise<Contact[]> {
|
|
210
|
+
const response = await client.get('/contacts');
|
|
211
|
+
return response.items;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Avoid
|
|
215
|
+
function fetchContacts(): Promise<Contact[]> {
|
|
216
|
+
return client.get('/contacts').then(r => r.items);
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Adding New Tools
|
|
221
|
+
|
|
222
|
+
### 1. Define Types
|
|
223
|
+
|
|
224
|
+
Create or update `src/types/{entity}.ts`:
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
export interface MyEntity {
|
|
228
|
+
id: string;
|
|
229
|
+
name: string;
|
|
230
|
+
created_at: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface MyEntityCreateInput {
|
|
234
|
+
name: string;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### 2. Create Validation Schema
|
|
239
|
+
|
|
240
|
+
Add to `src/utils/validation.ts`:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
export const createMyEntitySchema = z.object({
|
|
244
|
+
name: z.string().min(1),
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### 3. Implement Tool
|
|
249
|
+
|
|
250
|
+
Create or update `src/tools/{entity}.ts`:
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
const myEntityTools: Tool[] = [
|
|
254
|
+
{
|
|
255
|
+
name: 'salesflare_myentities_create',
|
|
256
|
+
description: 'Create a new entity',
|
|
257
|
+
inputSchema: {
|
|
258
|
+
type: 'object',
|
|
259
|
+
properties: {
|
|
260
|
+
name: { type: 'string' },
|
|
261
|
+
},
|
|
262
|
+
required: ['name'],
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
// Handler
|
|
268
|
+
async function handleMyEntityCreate(args: unknown) {
|
|
269
|
+
// Validate input
|
|
270
|
+
// Call API
|
|
271
|
+
// Return formatted response
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### 4. Register Tool
|
|
276
|
+
|
|
277
|
+
Update `src/server.ts`:
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
import { registerMyEntityTools } from './tools/myentity.js';
|
|
281
|
+
|
|
282
|
+
// In createServer function:
|
|
283
|
+
registerMyEntityTools(server, client);
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### 5. Add Tests
|
|
287
|
+
|
|
288
|
+
Create `tests/unit/myentities-create.test.ts`:
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
import { describe, it, expect, jest, beforeEach } from '@jest/globals';
|
|
292
|
+
import { registerMyEntityTools } from '../../src/tools/myentity.js';
|
|
293
|
+
|
|
294
|
+
describe('salesflare_myentities_create', () => {
|
|
295
|
+
// Test setup...
|
|
296
|
+
|
|
297
|
+
it('should create entity successfully', async () => {
|
|
298
|
+
// Test implementation
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('should handle validation errors', async () => {
|
|
302
|
+
// Test validation
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### 6. Update Documentation
|
|
308
|
+
|
|
309
|
+
- Add tool to [API.md](API.md)
|
|
310
|
+
- Add example to [INSPECTOR.md](INSPECTOR.md)
|
|
311
|
+
- Update README.md tool list if needed
|
|
312
|
+
|
|
313
|
+
## Submitting PRs
|
|
314
|
+
|
|
315
|
+
### Before Submitting
|
|
316
|
+
|
|
317
|
+
1. **All tests must pass**
|
|
318
|
+
```bash
|
|
319
|
+
npm test
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
2. **Code coverage maintained**
|
|
323
|
+
- New code should have tests
|
|
324
|
+
- Overall coverage should stay above 80%
|
|
325
|
+
|
|
326
|
+
3. **Build succeeds**
|
|
327
|
+
```bash
|
|
328
|
+
npm run build
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
4. **TypeScript compiles without errors**
|
|
332
|
+
```bash
|
|
333
|
+
npx tsc --noEmit
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### PR Checklist
|
|
337
|
+
|
|
338
|
+
- [ ] Tests added for new functionality
|
|
339
|
+
- [ ] All tests pass
|
|
340
|
+
- [ ] Build succeeds
|
|
341
|
+
- [ ] Code follows style guidelines
|
|
342
|
+
- [ ] Documentation updated
|
|
343
|
+
- [ ] Commit messages follow conventional format
|
|
344
|
+
|
|
345
|
+
### Commit Message Format
|
|
346
|
+
|
|
347
|
+
We use conventional commits:
|
|
348
|
+
|
|
349
|
+
```
|
|
350
|
+
type(scope): description
|
|
351
|
+
|
|
352
|
+
Examples:
|
|
353
|
+
feat(contacts): add phone number validation
|
|
354
|
+
fix(api): handle 429 rate limit errors
|
|
355
|
+
docs(readme): update installation instructions
|
|
356
|
+
test(deals): add edge case tests for value conversion
|
|
357
|
+
refactor(client): extract retry logic to separate function
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Types:
|
|
361
|
+
- `feat`: New feature
|
|
362
|
+
- `fix`: Bug fix
|
|
363
|
+
- `docs`: Documentation changes
|
|
364
|
+
- `test`: Adding or updating tests
|
|
365
|
+
- `refactor`: Code refactoring
|
|
366
|
+
- `chore`: Build/config changes
|
|
367
|
+
|
|
368
|
+
### PR Process
|
|
369
|
+
|
|
370
|
+
1. **Fork the repository**
|
|
371
|
+
2. **Create a feature branch** (`git checkout -b feature/my-feature`)
|
|
372
|
+
3. **Make your changes**
|
|
373
|
+
4. **Commit with descriptive messages**
|
|
374
|
+
5. **Push to your fork**
|
|
375
|
+
6. **Submit a Pull Request**
|
|
376
|
+
|
|
377
|
+
## Release Process
|
|
378
|
+
|
|
379
|
+
Releases are managed by maintainers:
|
|
380
|
+
|
|
381
|
+
1. Version bump in `package.json`
|
|
382
|
+
2. Update `CHANGELOG.md`
|
|
383
|
+
3. Create git tag
|
|
384
|
+
4. Publish to npm
|
|
385
|
+
5. Create GitHub release
|
|
386
|
+
|
|
387
|
+
## Questions?
|
|
388
|
+
|
|
389
|
+
- **General questions:** Open a GitHub Discussion
|
|
390
|
+
- **Bug reports:** Open a GitHub Issue
|
|
391
|
+
- **Security issues:** Email security@salesflare.com
|
|
392
|
+
|
|
393
|
+
## Code of Conduct
|
|
394
|
+
|
|
395
|
+
- Be respectful and inclusive
|
|
396
|
+
- Focus on constructive feedback
|
|
397
|
+
- Help others learn and grow
|
|
398
|
+
|
|
399
|
+
Thank you for contributing!
|
package/FIX_PLAN.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Salesflare MCP Tool Fixes - Action Plan
|
|
2
|
+
|
|
3
|
+
## Test Results Summary
|
|
4
|
+
- **Date**: 2025-06-02
|
|
5
|
+
- **Total Tests**: 17
|
|
6
|
+
- **Passed**: 8 (47.1%)
|
|
7
|
+
- **Failed**: 9 (52.9%)
|
|
8
|
+
|
|
9
|
+
## Issues by Category
|
|
10
|
+
|
|
11
|
+
### 1. DEALS - Wrong Endpoint
|
|
12
|
+
**Error**: `Resource not found: /deals`
|
|
13
|
+
|
|
14
|
+
**Root Cause**: Salesflare API uses `/opportunities` not `/deals`
|
|
15
|
+
|
|
16
|
+
**Fix**: Update `src/tools/deals.ts` line 270:
|
|
17
|
+
```typescript
|
|
18
|
+
// Change from:
|
|
19
|
+
}>('/deals', { params: queryParams });
|
|
20
|
+
|
|
21
|
+
// To:
|
|
22
|
+
}>('/opportunities', { params: queryParams });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### 2. TASKS - Schema Validation Errors
|
|
28
|
+
**Errors**:
|
|
29
|
+
- `Validation error: "page" is not allowed`
|
|
30
|
+
- `Validation error: "status" is not allowed`
|
|
31
|
+
|
|
32
|
+
**Root Cause**: Task Zod schemas are too restrictive
|
|
33
|
+
|
|
34
|
+
**Fix**: Update `src/utils/validation.ts`:
|
|
35
|
+
|
|
36
|
+
For task list schema, allow:
|
|
37
|
+
- `page` and `limit` for pagination
|
|
38
|
+
- `status` filter
|
|
39
|
+
|
|
40
|
+
For task create schema:
|
|
41
|
+
- Remove `.strict()` to allow optional fields like `status`
|
|
42
|
+
- Or explicitly add `status` to schema
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### 3. PIPELINE - Response Format Issues
|
|
47
|
+
**Error**: `Cannot read properties of undefined (reading 'map')`
|
|
48
|
+
|
|
49
|
+
**Root Cause**: Pipeline API returns different response format than expected
|
|
50
|
+
|
|
51
|
+
**Fix**: Update `src/tools/pipeline.ts`:
|
|
52
|
+
|
|
53
|
+
Add defensive checks for response format:
|
|
54
|
+
```typescript
|
|
55
|
+
const pipelines = Array.isArray(response) ? response : response.items || [];
|
|
56
|
+
const stages = Array.isArray(response) ? response : response.items || [];
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Quick Fixes Priority
|
|
62
|
+
|
|
63
|
+
1. **HIGH**: Fix deals endpoint (`/deals` → `/opportunities`)
|
|
64
|
+
2. **HIGH**: Fix task validation schemas
|
|
65
|
+
3. **MEDIUM**: Fix pipeline response handling
|
|
66
|
+
|
|
67
|
+
## Expected Result After Fixes
|
|
68
|
+
- Success rate should increase from 47% to ~90%+
|
|
69
|
+
- All list operations should work
|
|
70
|
+
- Create operations should work for contacts, companies, deals, tasks
|