|
1 | 1 | # Affinity MCP Server |
2 | 2 |
|
3 | | -An MCP (Model Context Protocol) server that provides integration with [Affinity CRM](https://affinity.co) through their REST API. |
4 | | - |
5 | | -## Features |
6 | | - |
7 | | -This MCP server provides tools to interact with Affinity CRM, including: |
8 | | - |
9 | | -### Lists |
10 | | -- Get all lists |
11 | | -- Get a specific list by ID |
12 | | -- Create new lists |
13 | | - |
14 | | -### List Entries |
15 | | -- Get list entries for a specific list |
16 | | -- Get a specific list entry by ID |
17 | | -- Create new list entries |
18 | | -- Delete list entries |
19 | | - |
20 | | -### Persons |
21 | | -- Search for persons |
22 | | -- Get a specific person by ID |
23 | | -- Create new persons |
24 | | -- Update existing persons |
25 | | -- Delete persons |
26 | | - |
27 | | -### Organizations |
28 | | -- Search for organizations |
29 | | -- Get a specific organization by ID |
30 | | -- Create new organizations |
31 | | -- Update existing organizations |
32 | | -- Delete organizations |
33 | | - |
34 | | -### Opportunities |
35 | | -- Search for opportunities |
36 | | -- Get a specific opportunity by ID |
37 | | -- Create new opportunities |
38 | | -- Update existing opportunities |
39 | | -- Delete opportunities |
40 | | - |
41 | | -### Notes |
42 | | -- Get notes (optionally filtered by person, organization, or opportunity) |
43 | | -- Get a specific note by ID |
44 | | -- Create new notes |
45 | | -- Update existing notes |
46 | | -- Delete notes |
47 | | - |
48 | | -### Field Values |
49 | | -- Get field values for entities |
50 | | -- Create new field values |
51 | | -- Update existing field values |
52 | | -- Delete field values |
53 | | - |
54 | | -## Setup |
55 | | - |
56 | | -### Prerequisites |
57 | | -- Python 3.12 or higher |
58 | | -- An Affinity account with API access |
59 | | -- Affinity API key (obtain from Settings Panel in Affinity web app) |
60 | | - |
61 | | -### Installation |
62 | | - |
63 | | -1. Install the required dependencies: |
64 | | -```bash |
65 | | -pip install -r requirements.txt |
66 | | -``` |
| 3 | +A Model Context Protocol (MCP) server for Affinity CRM integration. Manage relationships, deals, and business networks using Affinity's API with OAuth support. |
67 | 4 |
|
68 | | -2. Set up your environment variables: |
69 | | -```bash |
70 | | -export AFFINITY_MCP_SERVER_PORT=5000 # Optional, defaults to 5000 |
71 | | -``` |
| 5 | +## 🚀 Quick Start - Run in 30 Seconds |
72 | 6 |
|
73 | | -3. Run the server: |
74 | | -```bash |
75 | | -python server.py |
76 | | -``` |
| 7 | +### 🌐 Using Hosted Service (Recommended for Production) |
77 | 8 |
|
78 | | -### Docker Setup |
| 9 | +Get instant access to Affinity with our managed infrastructure - **no setup required**: |
79 | 10 |
|
80 | | -1. Build the Docker image: |
81 | | -```bash |
82 | | -docker build -f mcp_servers/affinity/Dockerfile -t affinity-mcp-server . |
83 | | -``` |
| 11 | +**🔗 [Get Free API Key →](https://www.klavis.ai/home/api-keys)** |
84 | 12 |
|
85 | | -2. Run the container: |
86 | 13 | ```bash |
87 | | -docker run -p 5000:5000 affinity-mcp-server |
| 14 | +pip install klavis |
| 15 | +# or |
| 16 | +npm install klavis |
88 | 17 | ``` |
89 | 18 |
|
90 | | -## Authentication |
| 19 | +```python |
| 20 | +from klavis import Klavis |
91 | 21 |
|
92 | | -The server uses a custom authentication header with your Affinity API key. The API key should be provided in the `x-auth-token` header: |
93 | | - |
94 | | -``` |
95 | | -x-auth-token: your_api_key_here |
| 22 | +klavis = Klavis(api_key="your-free-key") |
| 23 | +server = klavis.mcp_server.create_server_instance("AFFINITY", "user123") |
96 | 24 | ``` |
97 | 25 |
|
98 | | -## API Endpoints |
99 | | - |
100 | | -The server provides endpoints for both transport methods: |
101 | | - |
102 | | -- `/sse` - Server-Sent Events endpoint for real-time communication |
103 | | -- `/messages/` - SSE message handling endpoint |
104 | | -- `/mcp` - StreamableHTTP endpoint for direct API calls |
| 26 | +### 🐳 Using Docker (For Self-Hosting) |
105 | 27 |
|
106 | | -## Tool Usage Examples |
| 28 | +```bash |
| 29 | +# Run Affinity MCP Server (OAuth support through Klavis AI) |
| 30 | +docker run -p 5000:5000 -e KLAVIS_API_KEY=your_free_key \ |
| 31 | + ghcr.io/klavis-ai/affinity-mcp-server:latest |
107 | 32 |
|
108 | | -### Get All Lists |
109 | | -```json |
110 | | -{ |
111 | | - "name": "affinity_get_lists", |
112 | | - "arguments": {} |
113 | | -} |
| 33 | +# Run Affinity MCP Server (no OAuth support) |
| 34 | +docker run -p 5000:5000 -e AUTH_DATA='{"access_token":"your_affinity_api_key_here"}' \ |
| 35 | + ghcr.io/klavis-ai/affinity-mcp-server:latest |
114 | 36 | ``` |
115 | 37 |
|
116 | | -### Search for Persons |
117 | | -```json |
118 | | -{ |
119 | | - "name": "affinity_search_persons", |
120 | | - "arguments": { |
121 | | - "term": "john@example.com", |
122 | | - "page_size": 10 |
123 | | - } |
124 | | -} |
125 | | -``` |
| 38 | +**OAuth Setup:** Affinity requires OAuth authentication. Use `KLAVIS_API_KEY` from your [free API key](https://www.klavis.ai/home/api-keys) to handle the OAuth flow automatically. |
126 | 39 |
|
127 | | -### Create a Person |
128 | | -```json |
129 | | -{ |
130 | | - "name": "affinity_create_person", |
131 | | - "arguments": { |
132 | | - "first_name": "John", |
133 | | - "last_name": "Doe", |
134 | | - "emails": ["john@example.com"], |
135 | | - "organization_ids": [123] |
136 | | - } |
137 | | -} |
138 | | -``` |
| 40 | +## 🛠️ Available Tools |
139 | 41 |
|
140 | | -### Create a Note |
141 | | -```json |
142 | | -{ |
143 | | - "name": "affinity_create_note", |
144 | | - "arguments": { |
145 | | - "content": "Meeting notes from today's call", |
146 | | - "person_ids": [456], |
147 | | - "type": 0 |
148 | | - } |
149 | | -} |
150 | | -``` |
| 42 | +- **Relationship Management**: Manage people, organizations, and relationships |
| 43 | +- **Deal Tracking**: Handle opportunities and deal pipeline |
| 44 | +- **List Operations**: Create and manage custom lists and fields |
| 45 | +- **Network Analysis**: Analyze relationship networks and connections |
| 46 | +- **Data Sync**: Sync data with external systems and integrations |
151 | 47 |
|
152 | | -## Error Handling |
| 48 | +## 📚 Documentation & Support |
153 | 49 |
|
154 | | -The server provides detailed error messages for common issues: |
155 | | -- Missing required parameters |
156 | | -- Authentication failures |
157 | | -- API rate limiting |
158 | | -- Network connectivity issues |
| 50 | +| Resource | Link | |
| 51 | +|----------|------| |
| 52 | +| **📖 Documentation** | [docs.klavis.ai](https://docs.klavis.ai) | |
| 53 | +| **💬 Discord** | [Join Community](https://discord.gg/p7TuTEcssn) | |
| 54 | +| **🐛 Issues** | [GitHub Issues](https://github.com/klavis-ai/klavis/issues) | |
159 | 55 |
|
160 | | -## Rate Limiting |
| 56 | +## 🤝 Contributing |
161 | 57 |
|
162 | | -Affinity API has rate limits. The server will handle rate limit responses appropriately. See the [Affinity API documentation](https://api-docs.affinity.co/#rate-limits) for current limits. |
| 58 | +We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details. |
163 | 59 |
|
164 | | -## Contributing |
| 60 | +## 📜 License |
165 | 61 |
|
166 | | -1. Follow the existing code structure |
167 | | -2. Add new tools to the appropriate files in the `tools/` directory |
168 | | -3. Update `tools/__init__.py` to export new functions |
169 | | -4. Add tool definitions to `server.py` |
170 | | -5. Update this README with new functionality |
| 62 | +MIT License - see [LICENSE](../../LICENSE) for details. |
171 | 63 |
|
172 | | -## License |
| 64 | +--- |
173 | 65 |
|
174 | | -This project follows the same license as the parent Klavis project. |
| 66 | +<div align="center"> |
| 67 | + <p><strong>🚀 Supercharge AI Applications </strong></p> |
| 68 | + <p> |
| 69 | + <a href="https://www.klavis.ai">Get Free API Key</a> • |
| 70 | + <a href="https://docs.klavis.ai">Documentation</a> • |
| 71 | + <a href="https://discord.gg/p7TuTEcssn">Discord</a> |
| 72 | + </p> |
| 73 | +</div> |
0 commit comments