Connect to MCP servers and integrate LLM tools across providers (Anthropic, OpenAI, Google, Amazon, Meta, Mistral). List, search, and execute tools with provider-specific formatting.
Integrate Primrose SDK to connect to MCP servers and access LLM tools formatted for different providers.
This skill helps you integrate the Primrose SDK into a project to:
When the user asks to integrate Primrose MCP or set up MCP tool integration:
1. **Install the package**
- Run: `npm install primrose-mcp` (or pnpm/yarn equivalent)
- Verify installation in package.json
2. **Ask for configuration details** using AskUserQuestion:
- API key (they should have a Primrose API key starting with `prm_`)
- LLM provider they want to use (anthropic, openai, google, amazon, meta, mistral, or generic)
- Where they want the integration (which file/module)
3. **Create or update integration code**
- Import Primrose: `import { Primrose } from 'primrose-mcp';`
- Initialize with config:
```typescript
const primrose = new Primrose({
apiKey: process.env.PRIMROSE_API_KEY || 'prm_xxxxx',
provider: 'anthropic' // or user's chosen provider
});
```
4. **Implement core functionality based on user needs**:
- **List all tools**: `const tools = await primrose.listTools();`
- **List from specific server**: `const tools = await primrose.listTools({ mcpServer: 'hubspot' });`
- **Search tools**: `const results = await primrose.searchTools('search query');`
- **Call a tool**:
```typescript
const result = await primrose.callTool('tool_name', {
param1: 'value1',
param2: 'value2'
});
```
5. **Add error handling**
- Wrap calls in try-catch blocks
- Import PrimroseError: `import { Primrose, PrimroseError } from 'primrose-mcp';`
- Handle specific error codes (UNAUTHORIZED, PAYMENT_REQUIRED, FORBIDDEN, NOT_FOUND, INTERNAL_ERROR, SERVICE_UNAVAILABLE)
- Example:
```typescript
try {
await primrose.callTool('some_tool', {});
} catch (error) {
if (error instanceof PrimroseError) {
console.error(`Error ${error.code}: ${error.message} (${error.status})`);
}
}
```
6. **Update environment variables**
- Add `PRIMROSE_API_KEY=prm_xxxxx` to `.env` or `.env.local`
- Ensure .env is in .gitignore
7. **Document provider formats if relevant**
- Anthropic: `{ name, description, input_schema }`
- OpenAI/Meta/Mistral: `{ type: 'function', function: { name, description, parameters } }`
- Google: `{ name, description, parameters }` with uppercase types
- Amazon: `{ toolSpec: { name, description, inputSchema: { json } } }`
- Generic: `{ name, description, parameters }`
**Example 1: Basic integration**
```typescript
import { Primrose } from 'primrose-mcp';
const primrose = new Primrose({
apiKey: process.env.PRIMROSE_API_KEY,
provider: 'anthropic'
});
const tools = await primrose.listTools();
console.log(`Found ${tools.length} tools`);
```
**Example 2: Search and execute tool**
```typescript
const results = await primrose.searchTools('create contact');
const result = await primrose.callTool('hubspot_create_contact', {
email: '[email protected]',
firstName: 'John',
lastName: 'Doe'
});
```
**Example 3: Error handling**
```typescript
try {
const tools = await primrose.listTools({ mcpServer: 'hubspot' });
} catch (error) {
if (error instanceof PrimroseError) {
if (error.code === 'UNAUTHORIZED') {
console.error('Invalid API key');
} else if (error.code === 'PAYMENT_REQUIRED') {
console.error('Subscription expired');
}
}
}
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/primrose-mcp-integration/raw