Skip to content

Latest commit

 

History

History
337 lines (262 loc) · 8.06 KB

File metadata and controls

337 lines (262 loc) · 8.06 KB

Respond.io MCP Server - Project Summary

Overview

A production-ready Model Context Protocol (MCP) server that provides seamless integration between AI assistants (like Claude) and the Respond.io customer engagement platform. Built with TypeScript following industry best practices.

Key Features

🎯 Complete API Coverage

  • Contact Management: Full CRUD operations, tagging, custom fields
  • Messaging: Multi-channel support (WhatsApp, Email, SMS, Social Media)
  • Conversations: Assignment, status management, closing notes
  • Workspace: Users, channels, custom fields management
  • Comments: Internal team collaboration

🛡️ Production-Ready

  • Type Safety: Full TypeScript with strict mode
  • Input Validation: Comprehensive validation for all inputs
  • Error Handling: Detailed error messages and recovery
  • Rate Limiting: Built-in rate limit handling
  • Logging: Structured logging for debugging

📚 Well-Documented

  • Complete API reference with examples
  • Step-by-step setup guide
  • Contributing guidelines
  • Security best practices
  • Troubleshooting documentation

Technical Stack

{
  "runtime": "Node.js 18+",
  "language": "TypeScript 5.3+",
  "protocol": "Model Context Protocol (MCP)",
  "code_quality": ["ESLint", "Prettier"],
  "architecture": "Modular, event-driven"
}

Project Structure

mcp-server/
├── src/
│   ├── index.ts          # Main server implementation
│   ├── types.ts          # TypeScript type definitions
│   ├── constants.ts      # Application constants
│   ├── utils/            # Utility functions
│   ├── middlewares/      # Express middlewares
│   └── tools/            # Tool definitions
├── dist/                 # Compiled JavaScript (auto-generated)
├── README.md             # Project overview, features, tool list, examples
├── SETUP_GUIDE.md        # Installation instructions
├── CONTRIBUTING.md       # Contribution guidelines
├── .env.example          # Environment configuration template
├── .eslintrc.json        # Code linting rules
├── .prettierrc.json      # Code formatting rules
├── tsconfig.json         # TypeScript compiler config
├── package.json          # Dependencies and scripts
├── LICENSE               # MIT License
└── .gitignore           # Git ignore rules

Available Tools (28 Total)

See README.md for the full list and usage examples. Response shapes and API behavior follow the Respond.io Developer API and the SDK.

Contact Management (11 tools)

get_contact, create_contact, update_contact, delete_contact, list_contacts, add_contact_tags, remove_contact_tags, create_or_update_contact, merge_contacts, list_contact_channels, update_contact_lifecycle

Messaging (3 tools)

send_message, get_message, list_messages

Conversations (2 tools)

assign_conversation, update_conversation_status

Comments (1 tool)

create_comment

Workspace Management (11 tools)

list_users, get_user, list_custom_fields, get_custom_field, create_custom_field, list_channels, list_closing_notes, list_templates, create_tag, update_tag, delete_tag

Code Quality Standards

TypeScript Configuration

{
  "strict": true,
  "noUnusedLocals": true,
  "noUnusedParameters": true,
  "noImplicitReturns": true,
  "noFallthroughCasesInSwitch": true
}

ESLint Rules

  • TypeScript recommended rules
  • Prettier integration
  • No unused variables
  • Explicit function return types (where needed)
  • No floating promises

Code Style

  • 2-space indentation
  • Semicolons required
  • Single quotes disabled (double quotes)
  • 100 character line limit
  • Trailing commas (ES5)

Security Features

  1. API Key Protection

    • Environment variable storage
    • Never logged or exposed
    • Rotation support
  2. Input Sanitization

    • All inputs validated
    • SQL injection prevention
    • XSS protection
  3. Rate Limiting

    • Built-in rate limit handling
    • Exponential backoff
    • Request queueing
  4. Error Handling

    • No sensitive data in errors
    • Proper error codes
    • Detailed logging

Performance Optimizations

  • Connection Pooling: Reusable HTTP connections
  • Timeout Management: 30-second default timeout
  • Retry Logic: Exponential backoff for failures
  • Pagination: Efficient data retrieval
  • Type Safety: Reduced runtime errors

Development Workflow

# Setup
npm install
cp .env.example .env

# Development
npm run dev        # Hot reload
npm run type-check # Type checking
npm run lint       # Code linting
npm run format     # Code formatting

# Production
npm run build      # Compile TypeScript
npm start          # Run compiled code

# Quality Checks
npm run lint:fix   # Auto-fix linting issues

Testing Strategy

Manual Testing

  • Contact operations tested
  • Message sending verified
  • Conversation management validated
  • Error scenarios covered

Validation Testing

  • Input validation for all parameters
  • Type checking at compile time
  • Runtime validation for API responses

Integration Testing

  • Real API endpoint testing
  • Claude Desktop integration verified
  • Multi-tool workflows tested

API Rate Limits & Errors

Respond.io API enforces rate limits (429 handling, retry with backoff). For error types, response format, and environment variables, see README.md and README.md.

Dependencies

Production

  • @modelcontextprotocol/sdk: MCP protocol implementation
  • @respond-io/typescript-sdk: Respond.io API SDK (includes HTTP client internally)
  • dotenv: Environment configuration

Development

  • typescript: Type safety
  • tsx: TypeScript execution
  • eslint: Code linting
  • prettier: Code formatting
  • @types/node: Node.js type definitions

Deployment Options

1. Local Development

npm run dev

2. Production Build

npm run build
npm start

3. Global Installation

npm install -g .
mcp-server

4. Docker (Future)

FROM node:18-alpine
WORKDIR /app
COPY . .
RUN npm install && npm run build
CMD ["npm", "start"]

Use Cases

Customer Support

  • Assign conversations to agents
  • Send automated responses
  • Track conversation status
  • Add internal notes

Sales & Marketing

  • Tag leads and customers
  • Send targeted WhatsApp campaigns
  • Track customer lifecycle
  • Manage contact custom fields

Automation

  • Auto-respond to inquiries
  • Route conversations by topic
  • Update CRM data
  • Generate reports

Integration

  • Connect with AI assistants
  • Sync with other systems
  • Automate workflows
  • Real-time updates

Best Practices

1. API Key Management

# ✅ Good
export RESPONDIO_API_KEY=secret_key

# ❌ Bad
const apiKey = "secret_key"; // Hardcoded

2. Error Handling

// ✅ Good
try {
  await sendMessage(args);
} catch (error) {
  logger.error("Failed to send:", error);
  return { error: handleApiError(error) };
}

// ❌ Bad
await sendMessage(args); // Unhandled

3. Input Validation

// ✅ Good
const validation = validateIdentifier(identifier);
if (!validation.valid) {
  return { error: validation.errors.join(", ") };
}

// ❌ Bad
// No validation

4. Type Safety

// ✅ Good
interface SendMessageArgs {
  identifier: string;
  messageType: MessageType;
}

// ❌ Bad
function sendMessage(args: any) { }

Roadmap

Version 1.1

  • Webhook support
  • Bulk operations
  • Advanced filtering
  • Contact merge

Version 1.2

  • Analytics tools
  • Scheduled messages
  • Template management
  • Workflow automation

Version 2.0

  • API v3 support
  • GraphQL integration
  • Enhanced caching
  • Multi-workspace

Quick Links


Built with ❤️ using TypeScript and Model Context Protocol

Last Updated: 2024