webex-bot-mcp 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ # Webex Bot MCP Environment Variables
2
+
3
+ # Your Webex Access Token (required)
4
+ # Get this from https://developer.webex.com/docs/getting-started
5
+ WEBEX_ACCESS_TOKEN=your_webex_access_token_here
@@ -0,0 +1,33 @@
1
+ # Environment Configuration Template
2
+ # Copy this to .env and fill in your actual values
3
+
4
+ # Required: Webex Bot Access Token
5
+ # Get this from https://developer.webex.com after creating a bot
6
+ WEBEX_ACCESS_TOKEN=your_bot_token_here
7
+
8
+ # Optional: Enable debug logging (true/false)
9
+ WEBEX_DEBUG=false
10
+
11
+ # Optional: Rate limiting configuration
12
+ WEBEX_RATE_LIMIT_MESSAGES_PER_SECOND=10
13
+ WEBEX_RATE_LIMIT_API_CALLS_PER_MINUTE=300
14
+
15
+ # Optional: Default room settings
16
+ WEBEX_DEFAULT_ROOM_TYPE=group
17
+ WEBEX_DEFAULT_MESSAGE_FORMAT=markdown
18
+
19
+ # Optional: Organization settings
20
+ WEBEX_ORG_DOMAIN=your-company.com
21
+ WEBEX_DEFAULT_MODERATORS=admin@your-company.com
22
+
23
+ # Optional: Logging configuration
24
+ LOG_LEVEL=INFO
25
+ LOG_FORMAT=json
26
+
27
+ # Optional: Monitoring and metrics
28
+ METRICS_ENABLED=false
29
+ METRICS_ENDPOINT=http://localhost:9090
30
+
31
+ # Security settings
32
+ WEBEX_VALIDATE_SSL=true
33
+ WEBEX_TIMEOUT_SECONDS=30
@@ -0,0 +1,63 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ build:
11
+ name: Build distribution
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+
20
+ - name: Install build tools
21
+ run: pip install build
22
+
23
+ - name: Build package
24
+ run: python -m build
25
+
26
+ - uses: actions/upload-artifact@v4
27
+ with:
28
+ name: dist
29
+ path: dist/
30
+
31
+ publish-testpypi:
32
+ name: Publish to TestPyPI
33
+ needs: build
34
+ runs-on: ubuntu-latest
35
+ environment: testpypi
36
+ permissions:
37
+ id-token: write
38
+ steps:
39
+ - uses: actions/download-artifact@v4
40
+ with:
41
+ name: dist
42
+ path: dist/
43
+
44
+ - name: Publish to TestPyPI
45
+ uses: pypa/gh-action-pypi-publish@release/v1
46
+ with:
47
+ repository-url: https://test.pypi.org/legacy/
48
+
49
+ publish-pypi:
50
+ name: Publish to PyPI
51
+ needs: publish-testpypi
52
+ runs-on: ubuntu-latest
53
+ environment: pypi
54
+ permissions:
55
+ id-token: write
56
+ steps:
57
+ - uses: actions/download-artifact@v4
58
+ with:
59
+ name: dist
60
+ path: dist/
61
+
62
+ - name: Publish to PyPI
63
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,13 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Environment variables
13
+ .env
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,121 @@
1
+ # Webex Bot MCP — Developer Guide
2
+
3
+ ## Project Overview
4
+
5
+ A Model Context Protocol (MCP) server that bridges AI assistants with the Webex Teams API.
6
+ It exposes tools for managing rooms, messages, and memberships, plus resources (contextual
7
+ guides) and prompt templates for common workflows.
8
+
9
+ ## Repository Layout
10
+
11
+ ```
12
+ main.py — MCP server entry point; registers all tools/resources/prompts
13
+ config.py — WebexConfig dataclass; loaded via get_config() or WebexConfig.from_env()
14
+ health_check.py — Standalone diagnostic script; validates env and API connectivity
15
+ pyproject.toml — Project metadata and dependencies (uses uv)
16
+ Dockerfile — Multi-stage build; non-root user, health checks
17
+ docker-compose.yml — Compose stack with optional Prometheus + Grafana
18
+
19
+ tools/
20
+ __init__.py — Re-exports every tool function
21
+ common.py — Shared: WebexAPI client, create_error_response, create_success_response,
22
+ WebexErrorCodes, version constants
23
+ rooms.py — Room/space CRUD (list, create, update, get, delete) + space aliases
24
+ messages.py — Message send/list/delete + mention helpers + space aliases
25
+ memberships.py — Membership CRUD (list, add, update, delete) + space aliases
26
+ people.py — get_webex_me, list_webex_people
27
+
28
+ tests/
29
+ test_messages.py — Unit tests (38 cases); mocks webexpythonsdk at sys.modules level
30
+ ```
31
+
32
+ ## Key Conventions
33
+
34
+ ### Tool count
35
+ 31 tools total: 5 room + 5 space-room aliases + 4 message + 2 space-message aliases +
36
+ 4 membership + 2 space-membership aliases + 2 people + 4 space-room/membership aliases.
37
+ Update `tools_count` in the `server_version` resource (`main.py`) when adding tools.
38
+
39
+ ### Error handling — always use structured responses
40
+ Every tool must return via `create_error_response` or `create_success_response` from
41
+ `tools/common.py`. Never return a bare `{'success': False, 'error': str(e)}` dict.
42
+ Map exceptions with a local `_map_exception_to_error(e)` helper (see any tool module for
43
+ the pattern).
44
+
45
+ Error code ranges:
46
+ - `E001–E003` — client/argument errors (do not retry)
47
+ - `E401–E404` — auth/access errors (do not retry)
48
+ - `E500–E504` — server errors (retry with backoff)
49
+ - `E600–E602` — Webex-specific errors
50
+
51
+ ### Response shape
52
+ ```python
53
+ # Error
54
+ {'success': False, 'error_code': 'E001', 'message': '...', 'timestamp': '<ISO>', 'server_version': '...'}
55
+
56
+ # Success
57
+ {'success': True, 'data': {...}, 'timestamp': '<ISO>', 'server_version': '...', 'metadata': {...}}
58
+ ```
59
+
60
+ ### Space aliases
61
+ Every room/message/membership tool has a "space" alias that delegates to the room variant
62
+ and renames keys in the response (`room` → `space`, `rooms` → `spaces`, etc.).
63
+ Aliases live in the same module file as the canonical tool.
64
+
65
+ ### `files` parameter
66
+ Always wrap a string URL in a list before sending to the SDK:
67
+ ```python
68
+ params['files'] = [files] if isinstance(files, str) else files
69
+ ```
70
+
71
+ ## Running the Server
72
+
73
+ ```bash
74
+ # stdio (default — for Claude Desktop / MCP clients)
75
+ uv run python main.py
76
+
77
+ # HTTP transport
78
+ uv run python main.py --transport streamable-http --host 0.0.0.0 --port 8000
79
+ ```
80
+
81
+ Required environment variable: `WEBEX_ACCESS_TOKEN`
82
+
83
+ ## Running Tests
84
+
85
+ ```bash
86
+ python -m unittest discover -s tests -v
87
+ ```
88
+
89
+ Tests mock `webexpythonsdk` via `sys.modules` so no real credentials are needed.
90
+
91
+ ## Adding a New Tool
92
+
93
+ 1. Implement the function in the appropriate `tools/*.py` module.
94
+ 2. Use `create_error_response` / `create_success_response` for all returns.
95
+ 3. Add a `_map_exception_to_error` call in the `except` block.
96
+ 4. Export from `tools/__init__.py`.
97
+ 5. Register with `mcp.tool()(your_function)` in `main.py`.
98
+ 6. Update `tools_count` in the `server_version` resource in `main.py`.
99
+ 7. Add unit tests in `tests/test_messages.py` (or a new test file).
100
+
101
+ ## Environment Variables
102
+
103
+ | Variable | Required | Default | Description |
104
+ |---|---|---|---|
105
+ | `WEBEX_ACCESS_TOKEN` | ✅ | — | Bot token from developer.webex.com |
106
+ | `WEBEX_DEBUG` | | `false` | Enable debug logging |
107
+ | `WEBEX_RATE_LIMIT_MESSAGES_PER_SECOND` | | `10` | Message rate limit |
108
+ | `WEBEX_RATE_LIMIT_API_CALLS_PER_MINUTE` | | `300` | API rate limit |
109
+ | `WEBEX_TIMEOUT_SECONDS` | | `30` | HTTP timeout |
110
+ | `LOG_LEVEL` | | `INFO` | `DEBUG`, `INFO`, `WARNING`, or `ERROR` |
111
+ | `LOG_FORMAT` | | `text` | `text` or `json` |
112
+ | `METRICS_ENABLED` | | `false` | Enable metrics endpoint |
113
+ | `METRICS_ENDPOINT` | | — | Prometheus push endpoint |
114
+
115
+ ## Dependency Management
116
+
117
+ Uses `uv`. The declared runtime dependency for dotenv is `python-dotenv>=1.0.0`
118
+ (not the unrelated `dotenv` PyPI package). After changing `pyproject.toml` run:
119
+ ```bash
120
+ uv lock && uv sync
121
+ ```
@@ -0,0 +1,183 @@
1
+ # Webex Bot MCP Server Configuration
2
+
3
+ This file provides deployment guidance and configuration options for production use.
4
+
5
+ ## Production Deployment Checklist
6
+
7
+ ### Security Configuration
8
+ - [ ] Bot token stored in secure environment variables (not in code)
9
+ - [ ] SSL/TLS enabled for all communications
10
+ - [ ] Regular token rotation schedule established
11
+ - [ ] Access logging enabled
12
+ - [ ] Rate limiting configured
13
+ - [ ] Input validation implemented
14
+
15
+ ### Monitoring & Observability
16
+ - [ ] Application logs configured (structured logging recommended)
17
+ - [ ] Metrics collection enabled
18
+ - [ ] Health check endpoints configured
19
+ - [ ] Error tracking and alerting set up
20
+ - [ ] Performance monitoring dashboard created
21
+
22
+ ### High Availability & Scale
23
+ - [ ] Container orchestration configured (if using containers)
24
+ - [ ] Load balancing configured (for HTTP transport)
25
+ - [ ] Graceful shutdown handling implemented
26
+ - [ ] Resource limits defined
27
+ - [ ] Auto-scaling policies configured
28
+
29
+ ### Compliance & Governance
30
+ - [ ] Data retention policies defined
31
+ - [ ] Audit logging enabled
32
+ - [ ] Compliance framework alignment verified
33
+ - [ ] Privacy policies updated
34
+ - [ ] User consent mechanisms implemented
35
+
36
+ ## Environment Variables Reference
37
+
38
+ ### Required
39
+ - `WEBEX_ACCESS_TOKEN`: Bot access token from Webex Developer Portal
40
+
41
+ ### Optional Configuration
42
+ - `WEBEX_DEBUG`: Enable debug logging (default: false)
43
+ - `WEBEX_RATE_LIMIT_MESSAGES_PER_SECOND`: Message rate limit (default: 10)
44
+ - `WEBEX_RATE_LIMIT_API_CALLS_PER_MINUTE`: API call rate limit (default: 300)
45
+ - `LOG_LEVEL`: Logging verbosity (DEBUG, INFO, WARN, ERROR)
46
+ - `METRICS_ENABLED`: Enable metrics collection (default: false)
47
+
48
+ ### Transport Configuration
49
+ - `MCP_TRANSPORT`: Transport type (stdio, streamable-http)
50
+ - `MCP_HOST`: Host binding for HTTP transport (default: localhost)
51
+ - `MCP_PORT`: Port binding for HTTP transport (default: 8000)
52
+
53
+ ## Docker Deployment
54
+
55
+ ```dockerfile
56
+ FROM python:3.12-slim
57
+
58
+ WORKDIR /app
59
+ COPY requirements.txt .
60
+ RUN pip install -r requirements.txt
61
+
62
+ COPY . .
63
+ EXPOSE 8000
64
+
65
+ CMD ["python", "main.py", "--transport", "streamable-http", "--host", "0.0.0.0"]
66
+ ```
67
+
68
+ ## Kubernetes Deployment
69
+
70
+ ```yaml
71
+ apiVersion: apps/v1
72
+ kind: Deployment
73
+ metadata:
74
+ name: webex-bot-mcp
75
+ spec:
76
+ replicas: 2
77
+ selector:
78
+ matchLabels:
79
+ app: webex-bot-mcp
80
+ template:
81
+ metadata:
82
+ labels:
83
+ app: webex-bot-mcp
84
+ spec:
85
+ containers:
86
+ - name: webex-bot-mcp
87
+ image: webex-bot-mcp:latest
88
+ ports:
89
+ - containerPort: 8000
90
+ env:
91
+ - name: WEBEX_ACCESS_TOKEN
92
+ valueFrom:
93
+ secretKeyRef:
94
+ name: webex-secrets
95
+ key: access-token
96
+ resources:
97
+ limits:
98
+ memory: "512Mi"
99
+ cpu: "500m"
100
+ requests:
101
+ memory: "256Mi"
102
+ cpu: "250m"
103
+ ---
104
+ apiVersion: v1
105
+ kind: Service
106
+ metadata:
107
+ name: webex-bot-mcp-service
108
+ spec:
109
+ selector:
110
+ app: webex-bot-mcp
111
+ ports:
112
+ - port: 80
113
+ targetPort: 8000
114
+ type: LoadBalancer
115
+ ```
116
+
117
+ ## Claude Desktop Configuration
118
+
119
+ Add to your Claude Desktop config:
120
+
121
+ ```json
122
+ {
123
+ "mcpServers": {
124
+ "webex-bot": {
125
+ "command": "python",
126
+ "args": ["/path/to/webex-bot-mcp/main.py"],
127
+ "env": {
128
+ "WEBEX_ACCESS_TOKEN": "your_token_here"
129
+ }
130
+ }
131
+ }
132
+ }
133
+ ```
134
+
135
+ ## Common Issues & Solutions
136
+
137
+ ### Issue: "Token Invalid" Errors
138
+ **Solution**: Check token expiration, regenerate if needed, ensure proper environment variable setup.
139
+
140
+ ### Issue: Rate Limiting
141
+ **Solution**: Implement exponential backoff, respect API limits, consider request batching.
142
+
143
+ ### Issue: Memory Usage
144
+ **Solution**: Monitor for memory leaks, implement connection pooling, tune garbage collection.
145
+
146
+ ### Issue: High Latency
147
+ **Solution**: Use connection pooling, implement caching, optimize database queries if used.
148
+
149
+ ## Performance Tuning
150
+
151
+ ### Message Throughput Optimization
152
+ - Use bulk operations where possible
153
+ - Implement message queuing for high-volume scenarios
154
+ - Consider async/await patterns for concurrent operations
155
+
156
+ ### Resource Optimization
157
+ - Connection pooling for HTTP transport
158
+ - Memory-efficient data structures
159
+ - Proper cleanup of resources
160
+
161
+ ### Monitoring Metrics
162
+ - Message send success rate
163
+ - API response times
164
+ - Error rates by operation type
165
+ - Resource utilization (CPU, memory, network)
166
+
167
+ ## Security Best Practices
168
+
169
+ ### Token Management
170
+ - Store tokens in secure key management systems
171
+ - Implement token rotation automation
172
+ - Monitor for token compromise
173
+
174
+ ### Network Security
175
+ - Use HTTPS only in production
176
+ - Implement proper firewall rules
177
+ - Consider VPN or private network deployment
178
+
179
+ ### Data Protection
180
+ - Encrypt sensitive data at rest
181
+ - Implement audit logging
182
+ - Follow data retention policies
183
+ - Regular security assessments
@@ -0,0 +1,63 @@
1
+ # Multi-stage build for Webex Bot MCP Server
2
+ FROM python:3.12-slim as builder
3
+
4
+ # Install build dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ build-essential \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ # Set working directory
10
+ WORKDIR /app
11
+
12
+ # Copy requirements and install dependencies
13
+ COPY pyproject.toml ./
14
+ RUN pip install --no-cache-dir -e .
15
+
16
+ # Production stage
17
+ FROM python:3.12-slim as production
18
+
19
+ # Create non-root user for security
20
+ RUN groupadd -r webexbot && useradd -r -g webexbot webexbot
21
+
22
+ # Install runtime dependencies
23
+ RUN apt-get update && apt-get install -y \
24
+ ca-certificates \
25
+ && rm -rf /var/lib/apt/lists/*
26
+
27
+ # Set working directory
28
+ WORKDIR /app
29
+
30
+ # Copy installed packages from builder
31
+ COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
32
+ COPY --from=builder /usr/local/bin /usr/local/bin
33
+
34
+ # Copy application code
35
+ COPY main.py ./
36
+ COPY tools/ ./tools/
37
+ COPY config.py ./
38
+ COPY health_check.py ./
39
+ COPY .env.template ./
40
+
41
+ # Change ownership to non-root user
42
+ RUN chown -R webexbot:webexbot /app
43
+
44
+ # Switch to non-root user
45
+ USER webexbot
46
+
47
+ # Create volume for configuration
48
+ VOLUME ["/app/config"]
49
+
50
+ # Expose port for HTTP transport
51
+ EXPOSE 8000
52
+
53
+ # Health check
54
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
55
+ CMD python health_check.py --skip-rooms --exit-code || exit 1
56
+
57
+ # Default command
58
+ CMD ["python", "main.py", "--transport", "streamable-http", "--host", "0.0.0.0", "--port", "8000"]
59
+
60
+ # Metadata
61
+ LABEL maintainer="Webex Bot MCP Team"
62
+ LABEL description="Webex Bot Model Context Protocol Server"
63
+ LABEL version="1.0.0"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 WebexCommunity
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.