MCP Client Examples
Learn how to quickly connect to the Slack MCP server and interact with Slack through ready-to-run client examples. These examples demonstrate different transport methods and integration patterns for building your own MCP clients.
🚀 Quick Start
1. Start the MCP Server
First, start the MCP server in HTTP mode with integrated capabilities:
# Option 1: Using the integrated MCP server
uv run slack-mcp-server --transport sse --mount-path /mcp --integrated
# Option 2: Using the webhook server with MCP integration
uv run slack-events-server --mcp-transport sse --mcp-mount-path /mcp --integrated
2. Run Client Examples
Navigate to the examples directory and run any client:
cd examples/mcp_clients
# SSE transport examples
python easy_mcp_client_with_sse.py
python easy_mcp_client_with_sse_in_web.py
# Streamable HTTP transport examples
python easy_mcp_client_with_streamable_http.py
python easy_mcp_client_with_streamable_http_in_web.py
📄 Source Files:
easy_mcp_client_with_sse.pyeasy_mcp_client_with_sse_in_web.pyeasy_mcp_client_with_streamable_http.pyeasy_mcp_client_with_streamable_http_in_web.py
📂 Available Examples
| Example Script | Transport | Endpoint | Best For |
|---|---|---|---|
easy_mcp_client_with_sse.py | SSE | http://localhost:9000/sse | Real-time applications, simple integration |
easy_mcp_client_with_sse_in_web.py | SSE | http://localhost:9000/mcp/sse | Web applications, browser compatibility |
easy_mcp_client_with_streamable_http.py | HTTP | http://localhost:9000/mcp | HTTP-based apps, REST-like patterns |
easy_mcp_client_with_streamable_http_in_web.py | HTTP | http://localhost:9000/mcp/mcp | Web integration with HTTP streaming |
Endpoint Configuration
The actual endpoint URLs depend on your server's base URL path configuration:
- Integrated mode (web applications) uses the default base path
/mcp, which prefixes all endpoints - Standalone mode examples don't use a base path prefix
- Custom mount path: When you start the server with
--mount-path /custom, the endpoints become/custom/sseand/custom
See the Server Configuration section below for detailed examples.
🔧 Transport Methods
Server-Sent Events (SSE)
Endpoints:
http://localhost:9000/sse(basic example)http://localhost:9000/mcp/sse(web integration example)
SSE provides real-time streaming communication ideal for applications requiring immediate updates.
import asyncio
from mcp import ClientSession
from mcp.client.sse import sse_client
async def mcp_client():
url = "http://localhost:9000/mcp/sse"
async with sse_client(url) as (read_stream, write_stream):
async with ClientSession(read_stream, write_stream) as session:
await session.initialize()
# Your MCP operations here
Streamable HTTP
Endpoints:
http://localhost:9000/mcp(basic example)http://localhost:9000/mcp/mcp(web integration example)
HTTP streaming provides bidirectional communication over a single HTTP connection.
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def mcp_client():
url = "http://localhost:9000/mcp"
async with streamablehttp_client(url) as (read_stream, write_stream, _close_fn):
async with ClientSession(read_stream, write_stream) as session:
await session.initialize()
# Your MCP operations here