A Python client for connecting to Model Context Protocol (MCP) servers, with built-in support for Slack, Salesforce, and Google Drive integrations.
- Multi-Service Support: Connect to Slack, Salesforce, and Google Drive through MCP servers
- Unified Interface: Single client to manage all your service connections
- Async/Await Support: Built with modern Python async patterns
- Transport Flexibility: Supports WebSocket and stdio transports
- Authentication Handling: Built-in OAuth and API key management
- Error Handling: Robust error handling with fallback mechanisms
- Type Safety: Full type hints and Pydantic models
- Clone the repository:
git clone <repository-url>
cd pursuit-mcp-client- Install dependencies:
pip install -r requirements.txtOr install in development mode:
pip install -e .- Copy the environment template:
cp .env.example .env- Fill in your credentials in
.env:
SLACK_BOT_TOKEN=xoxb-your-slack-bot-token
SLACK_TEAM_ID=your-slack-team-idSALESFORCE_USERNAME=your-salesforce-username
SALESFORCE_PASSWORD=your-salesforce-password
SALESFORCE_SECURITY_TOKEN=your-security-token
SALESFORCE_DOMAIN=login # or test for sandboxGOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:8080/callbackimport asyncio
from mcp_client import UnifiedMCPClient
async def main():
client = UnifiedMCPClient()
try:
# Connect to services
slack = await client.connect_slack("ws://localhost:8001/mcp/slack")
salesforce = await client.connect_salesforce("ws://localhost:8002/mcp/salesforce")
gdrive = await client.connect_google_drive("ws://localhost:8003/mcp/gdrive")
# Use the services
channels = await slack.get_channels()
accounts = await salesforce.query("SELECT Id, Name FROM Account LIMIT 5")
files = await gdrive.list_files(page_size=10)
print(f"Found {len(channels)} Slack channels")
print(f"Found {accounts['totalSize']} Salesforce accounts")
print(f"Found {len(files['files'])} Google Drive files")
finally:
await client.disconnect_all()
asyncio.run(main())# Connect to Slack
slack = await client.connect_slack("stdio")
# Post a message
await slack.post_message("#general", "Hello from MCP Client! ๐ค")
# Get channels
channels = await slack.get_channels(limit=10)
# Search messages
results = await slack.search_messages("important", count=20)# Connect to Salesforce
salesforce = await client.connect_salesforce("stdio")
# Query records
accounts = await salesforce.query("SELECT Id, Name FROM Account LIMIT 10")
# Create a record
new_account = await salesforce.create_record("Account", {
"Name": "Test Account",
"Type": "Prospect"
})
# Update a record
await salesforce.update_record("Account", account_id, {
"Description": "Updated via MCP"
})# Connect to Google Drive
gdrive = await client.connect_google_drive("stdio")
# List files
files = await gdrive.list_files(page_size=20)
# Upload a file
await gdrive.upload_file(
name="test.txt",
content=b"Hello, world!",
mime_type="text/plain"
)
# Create a folder
folder = await gdrive.create_folder("My New Folder")pursuit-mcp-client/
โโโ mcp_client/
โ โโโ __init__.py # Main exports
โ โโโ client.py # Core MCP client
โ โโโ transport.py # Transport layer (WebSocket, stdio)
โ โโโ types.py # Type definitions
โ โโโ unified_client.py # Unified client interface
โ โโโ services/
โ โโโ __init__.py
โ โโโ base.py # Base service class
โ โโโ slack.py # Slack integration
โ โโโ salesforce.py # Salesforce integration
โ โโโ google_drive.py # Google Drive integration
โโโ examples/
โ โโโ basic_usage.py # Basic usage example
โ โโโ slack_example.py # Slack-specific example
โ โโโ salesforce_example.py # Salesforce-specific example
โ โโโ google_drive_example.py # Google Drive-specific example
โโโ config/
โ โโโ mcp_servers.json # MCP server configurations
โโโ requirements.txt # Python dependencies
โโโ pyproject.toml # Project configuration
โโโ README.md # This file
This client requires MCP servers to be running for each service. You can:
-
Use existing MCP servers:
-
Run servers locally using the provided configurations in
config/mcp_servers.json -
Use stdio transport if you have command-line MCP tools
Run the example scripts to see the client in action:
# Basic usage with all services
python examples/basic_usage.py
# Service-specific examples
python examples/slack_example.py
python examples/salesforce_example.py
python examples/google_drive_example.py# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black mcp_client/
# Type checking
mypy mcp_client/The client supports multiple transport mechanisms:
- WebSocket:
ws://localhost:8001/mcp/service - Stdio:
"stdio"(for command-line MCP tools) - Custom Transport: Implement the
Transportinterface
- Create a Slack app at https://api.slack.com/apps
- Add bot scopes:
chat:write,channels:read,users:read, etc. - Install the app to your workspace
- Copy the Bot User OAuth Token
- Use your Salesforce username and password
- Generate a security token from Setup > Personal Information > Reset Security Token
- For sandbox, use
test.salesforce.comas domain
- Create a project in Google Cloud Console
- Enable the Google Drive API
- Create OAuth 2.0 credentials
- Download the credentials file or use client ID/secret
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run the test suite
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the examples directory
- Review the configuration files
- Open an issue on GitHub
- Add more service integrations (Teams, Discord, etc.)
- Implement connection pooling
- Add retry mechanisms with exponential backoff
- Create a web UI for configuration
- Add comprehensive logging
- Support for MCP server discovery
- Plugin architecture for custom services
Happy coding! ๐