|
| 1 | +# TIM-MCP Development Guide |
| 2 | + |
| 3 | +This guide is for developers who want to contribute to or modify the TIM-MCP server itself. |
| 4 | + |
| 5 | +## Development Installation |
| 6 | + |
| 7 | +For developers who want to contribute to TIM-MCP or run it locally: |
| 8 | + |
| 9 | +```bash |
| 10 | +# Clone the repository |
| 11 | +git clone https://github.com/terraform-ibm-modules/tim-mcp.git |
| 12 | +cd tim-mcp |
| 13 | + |
| 14 | +# Install development dependencies |
| 15 | +uv sync |
| 16 | + |
| 17 | +# Run tests |
| 18 | +uv run pytest |
| 19 | + |
| 20 | +# Run the server locally (STDIO mode - default) |
| 21 | +uv run tim-mcp |
| 22 | + |
| 23 | +# Launch the MCP inspector |
| 24 | +npx @modelcontextprotocol/inspector uv run tim-mcp |
| 25 | +``` |
| 26 | + |
| 27 | +**Requirements:** |
| 28 | +- Python 3.11 or higher |
| 29 | +- [uv](https://docs.astral.sh/uv/) package manager |
| 30 | + |
| 31 | +## Local Development Configuration |
| 32 | + |
| 33 | +### For Claude Desktop |
| 34 | + |
| 35 | +```json |
| 36 | +{ |
| 37 | + "mcpServers": { |
| 38 | + "tim-terraform": { |
| 39 | + "command": "uv", |
| 40 | + "args": [ |
| 41 | + "run", |
| 42 | + "tim-mcp" |
| 43 | + ], |
| 44 | + "cwd": "/path/to/your/tim-mcp", |
| 45 | + "env": { |
| 46 | + "GITHUB_TOKEN": "your_github_token_here" |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +**Setup steps:** |
| 54 | +1. Clone the repository: `git clone https://github.com/terraform-ibm-modules/tim-mcp.git` |
| 55 | +2. Navigate to the directory: `cd tim-mcp` |
| 56 | +3. Install dependencies: `uv sync` |
| 57 | +4. Update the `cwd` path in the configuration above to match your local repository path |
| 58 | +5. Add the configuration to your Claude Desktop settings |
| 59 | + |
| 60 | +### For Claude Code |
| 61 | + |
| 62 | +```bash |
| 63 | +# Navigate to your tim-mcp directory first |
| 64 | +cd /path/to/your/tim-mcp |
| 65 | + |
| 66 | +# Add the local MCP server |
| 67 | +claude mcp add tim-mcp --env GITHUB_TOKEN=your_github_token_here -- uv run tim-mcp |
| 68 | +``` |
| 69 | + |
| 70 | +## Transport Modes |
| 71 | + |
| 72 | +TIM-MCP supports two transport modes for different deployment scenarios: |
| 73 | + |
| 74 | +### STDIO Mode (Default) |
| 75 | + |
| 76 | +STDIO is the default transport mode, perfect for MCP clients like Claude Desktop that spawn server processes on-demand. |
| 77 | + |
| 78 | +```bash |
| 79 | +# STDIO mode (default) |
| 80 | +tim-mcp |
| 81 | + |
| 82 | +# Explicit STDIO mode with debug logging |
| 83 | +tim-mcp --log-level DEBUG |
| 84 | +``` |
| 85 | + |
| 86 | +### HTTP Mode |
| 87 | + |
| 88 | +HTTP mode runs the server as a stateless web service, ideal for network deployments and multiple concurrent clients. |
| 89 | + |
| 90 | +```bash |
| 91 | +# HTTP mode with defaults (127.0.0.1:8000) |
| 92 | +tim-mcp --http |
| 93 | + |
| 94 | +# HTTP mode with custom port |
| 95 | +tim-mcp --http --port 8080 |
| 96 | + |
| 97 | +# HTTP mode with custom host and port |
| 98 | +tim-mcp --http --host 0.0.0.0 --port 9000 |
| 99 | + |
| 100 | +# HTTP mode with debug logging |
| 101 | +tim-mcp --http --log-level DEBUG |
| 102 | +``` |
| 103 | + |
| 104 | +**HTTP Server URLs:** |
| 105 | +- Server runs at: `http://host:port/` |
| 106 | +- MCP endpoint: `http://host:port/mcp` |
| 107 | + |
| 108 | +**Stateless Operation:** |
| 109 | +- No session IDs required for HTTP requests |
| 110 | +- Each request is processed independently |
| 111 | +- Ideal for load balancing and horizontal scaling |
| 112 | + |
| 113 | +**Production HTTPS:** |
| 114 | +For production deployments requiring HTTPS, use nginx as a reverse proxy: |
| 115 | + |
| 116 | +```nginx |
| 117 | +server { |
| 118 | + listen 443 ssl; |
| 119 | + server_name your-domain.com; |
| 120 | +
|
| 121 | + # SSL configuration |
| 122 | + ssl_certificate /path/to/your/cert.pem; |
| 123 | + ssl_certificate_key /path/to/your/key.pem; |
| 124 | +
|
| 125 | + location / { |
| 126 | + proxy_pass http://127.0.0.1:8000; |
| 127 | + proxy_set_header Host $host; |
| 128 | + proxy_set_header X-Real-IP $remote_addr; |
| 129 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 130 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 131 | + } |
| 132 | +} |
| 133 | +``` |
| 134 | + |
| 135 | +## Advanced Configuration |
| 136 | + |
| 137 | +### Environment Variables |
| 138 | + |
| 139 | +- `GITHUB_TOKEN` (optional): GitHub personal access token |
| 140 | + - **When to use:** Recommended for frequent usage to avoid GitHub API rate limits |
| 141 | + - **Not required for:** Basic functionality - the server works fine without it for light usage |
| 142 | + - **Permissions needed:** None (read-only access to public repositories) |
| 143 | + - **Create token at:** https://github.com/settings/tokens |
| 144 | + |
| 145 | +- `TIM_ALLOWED_NAMESPACES`: Comma-separated list of allowed module namespaces (default: `terraform-ibm-modules`) |
| 146 | +- `TIM_EXCLUDED_MODULES`: Comma-separated list of module IDs to exclude from search results |
| 147 | + |
| 148 | +### Debugging |
| 149 | + |
| 150 | +For development and debugging purposes: |
| 151 | + |
| 152 | +```bash |
| 153 | +# Run with debug logging |
| 154 | +tim-mcp --log-level DEBUG |
| 155 | + |
| 156 | +# Run with trace logging (very verbose) |
| 157 | +tim-mcp --log-level TRACE |
| 158 | +``` |
| 159 | + |
| 160 | +## Contributing |
| 161 | + |
| 162 | +You can report issues and request features for this module in GitHub issues in the module repo. See [Report an issue or request a feature](https://github.com/terraform-ibm-modules/.github/blob/main/.github/SUPPORT.md). |
0 commit comments