|
| 1 | +# Api2Pdf - PDF Generation, Powered by AWS Lambda MCP Server |
| 2 | + |
| 3 | +This MCP (Model Content Protocol) server provides access to Api2Pdf - PDF Generation, Powered by AWS Lambda API functionality through HTTP, HTTPS, and STDIO transport modes. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- transport mode support (HTTP and STDIO) |
| 8 | +- Dynamic configuration through HTTP headers |
| 9 | +- Automatic tool generation from API documentation |
| 10 | + |
| 11 | +## Building the Project |
| 12 | + |
| 13 | +1. Ensure you have Go 1.24.6 or later installed |
| 14 | +2. Clone the repository |
| 15 | +3. Build the project: |
| 16 | + |
| 17 | +```bash |
| 18 | +go build -o mcp-server |
| 19 | +``` |
| 20 | + |
| 21 | +## Running the Server |
| 22 | + |
| 23 | +The server can run in three modes based on the **TRANSPORT** environment variable: |
| 24 | + |
| 25 | +### HTTP Mode |
| 26 | + |
| 27 | +To run in HTTP mode, set the transport environment variable to "http" or "HTTP": |
| 28 | + |
| 29 | +```bash |
| 30 | +export TRANSPORT="http" # or "HTTP" or "HTTPS" |
| 31 | +export PORT="8181" # required |
| 32 | +``` |
| 33 | + |
| 34 | +Run the server: |
| 35 | +```bash |
| 36 | +./mcp-server |
| 37 | +``` |
| 38 | + |
| 39 | +#### Required Environment Variables for HTTP Mode: |
| 40 | +- `TRANSPORT`: Set to "HTTP" **(Required)** |
| 41 | +- `PORT`: Server port **(Required)** |
| 42 | + |
| 43 | +#### Configuration through HTTP Headers: |
| 44 | +In HTTP mode, API configuration is provided via HTTP headers for each request: |
| 45 | +- `API_BASE_URL`: **(Required)** Base URL for the API |
| 46 | +- `BEARER_TOKEN`: Bearer token for authentication |
| 47 | +- `API_KEY`: API key for authentication |
| 48 | +- `BASIC_AUTH`: Basic authentication credentials |
| 49 | + |
| 50 | +Cursor mcp.json settings: |
| 51 | + |
| 52 | +{ |
| 53 | + "mcpServers": { |
| 54 | + "your-mcp-server-http": { |
| 55 | + "url": "http://<host>:<port>/mcp", |
| 56 | + "headers": { |
| 57 | + "API_BASE_URL": "https://your-api-base-url", |
| 58 | + "BEARER_TOKEN": "your-bearer-token" |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +The server will start on the configured port with the following endpoints: |
| 65 | +- `/mcp`: HTTP endpoint for MCP communication (requires API_BASE_URL header) |
| 66 | +- `/`: Health check endpoint |
| 67 | + |
| 68 | +**Note**: At least one authentication header (BEARER_TOKEN, API_KEY, or BASIC_AUTH) should be provided unless the API explicitly doesn't require authentication. |
| 69 | + |
| 70 | +### HTTPS Mode |
| 71 | + |
| 72 | +To run in HTTPS mode, set the transport environment variable to "https" or "HTTPS": |
| 73 | + |
| 74 | +```bash |
| 75 | +export TRANSPORT="https" # or "HTTPS" |
| 76 | +export PORT="8443" # required |
| 77 | +export CERT_FILE="./certs/cert.pem" # required |
| 78 | +export KEY_FILE="./certs/key.pem" # required |
| 79 | +``` |
| 80 | + |
| 81 | +Run the server: |
| 82 | +```bash |
| 83 | +./mcp-server |
| 84 | +``` |
| 85 | + |
| 86 | +#### Required Environment Variables for HTTPS Mode: |
| 87 | +- `TRANSPORT`: Set to "HTTPS" **(Required)** |
| 88 | +- `PORT`: Server port **(Required)** |
| 89 | +- `CERT_FILE`: Path to SSL certificate file **(Required)** |
| 90 | +- `KEY_FILE`: Path to SSL private key file **(Required)** |
| 91 | + |
| 92 | +#### Configuration through HTTP Headers: |
| 93 | +In HTTPS mode, API configuration is provided via HTTP headers for each request: |
| 94 | +- `API_BASE_URL`: **(Required)** Base URL for the API |
| 95 | +- `BEARER_TOKEN`: Bearer token for authentication |
| 96 | +- `API_KEY`: API key for authentication |
| 97 | +- `BASIC_AUTH`: Basic authentication credentials |
| 98 | + |
| 99 | +Cursor mcp.json settings: |
| 100 | + |
| 101 | +{ |
| 102 | + "mcpServers": { |
| 103 | + "your-mcp-server-https": { |
| 104 | + "url": "https://<host>:<port>/mcp", |
| 105 | + "headers": { |
| 106 | + "API_BASE_URL": "https://your-api-base-url", |
| 107 | + "BEARER_TOKEN": "your-bearer-token" |
| 108 | + } |
| 109 | + } |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +The server will start on the configured port with the following endpoints: |
| 114 | +- `/mcp`: HTTPS endpoint for MCP communication (requires API_BASE_URL header) |
| 115 | +- `/`: Health check endpoint |
| 116 | + |
| 117 | +**Note**: At least one authentication header (BEARER_TOKEN, API_KEY, or BASIC_AUTH) should be provided unless the API explicitly doesn't require authentication. |
| 118 | + |
| 119 | +``` |
| 120 | +
|
| 121 | +### STDIO Mode |
| 122 | +
|
| 123 | +To run in STDIO mode, either set the transport environment variable to "stdio" or leave it unset (default): |
| 124 | +
|
| 125 | +```bash |
| 126 | +export TRANSPORT="stdio" # or leave unset for default |
| 127 | +export API_BASE_URL="https://your-api-base-url" |
| 128 | +export BEARER_TOKEN="your-bearer-token" |
| 129 | +``` |
| 130 | + |
| 131 | +Run the server: |
| 132 | +```bash |
| 133 | +./mcp-server |
| 134 | +``` |
| 135 | + |
| 136 | +#### Required Environment Variables for STDIO Mode: |
| 137 | +- `TRANSPORT`: Set to "stdio" or leave unset (default) |
| 138 | +- `API_BASE_URL`: Base URL for the API **(Required)** |
| 139 | +- `BEARER_TOKEN`: Bearer token for authentication |
| 140 | +- `API_KEY`: API key for authentication |
| 141 | +- `BASIC_AUTH`: Basic authentication credentials |
| 142 | + |
| 143 | +**Note**: At least one authentication environment variable (BEARER_TOKEN, API_KEY, or BASIC_AUTH) should be provided unless the API explicitly doesn't require authentication. |
| 144 | + |
| 145 | +Cursor mcp.json settings: |
| 146 | + |
| 147 | +{ |
| 148 | + "mcpServers": { |
| 149 | + "your-mcp-server-stdio": { |
| 150 | + "command": "<path-to-binary>/<mcpserver-binary-name>", |
| 151 | + "env": { |
| 152 | + "API_BASE_URL": "<api-base-url>", |
| 153 | + "BEARER_TOKEN": "<token>" |
| 154 | + } |
| 155 | + } |
| 156 | + } |
| 157 | +} |
| 158 | + |
| 159 | +## Environment Variable Case Sensitivity |
| 160 | + |
| 161 | +The server supports both uppercase and lowercase transport environment variables: |
| 162 | +- `TRANSPORT` (uppercase) - checked first |
| 163 | +- `transport` (lowercase) - fallback if uppercase not set |
| 164 | + |
| 165 | +Valid values: "http", "HTTP", "https", "HTTPS", "stdio", or unset (defaults to STDIO) |
| 166 | + |
| 167 | +## Authentication |
| 168 | + |
| 169 | +### HTTP Mode |
| 170 | +Authentication is provided through HTTP headers on each request: |
| 171 | +- `BEARER_TOKEN`: Bearer token |
| 172 | +- `API_KEY`: API key |
| 173 | +- `BASIC_AUTH`: Basic authentication |
| 174 | + |
| 175 | +### STDIO Mode |
| 176 | +Authentication is provided through environment variables: |
| 177 | +- `BEARER_TOKEN`: Bearer token |
| 178 | +- `API_KEY`: API key |
| 179 | +- `BASIC_AUTH`: Basic authentication |
| 180 | + |
| 181 | +## Health Check |
| 182 | + |
| 183 | +When running in HTTP mode, you can check server health at the root endpoint (`/`). |
| 184 | +Expected response: `{"status":"ok"}` |
| 185 | + |
| 186 | +## Transport Modes Summary |
| 187 | + |
| 188 | +### HTTP Mode (TRANSPORT=http or TRANSPORT=HTTP) |
| 189 | +- Uses streamable HTTP server |
| 190 | +- Configuration provided via HTTP headers for each request |
| 191 | +- Requires API_BASE_URL header for each request |
| 192 | +- Endpoint: `/mcp` |
| 193 | +- Port configured via PORT environment variable (defaults to 8080) |
| 194 | + |
| 195 | +### HTTPS Mode (TRANSPORT=https or TRANSPORT=HTTPS) |
| 196 | +- Uses streamable HTTPS server with SSL/TLS encryption |
| 197 | +- Configuration provided via HTTP headers for each request |
| 198 | +- Requires API_BASE_URL header for each request |
| 199 | +- Endpoint: `/mcp` |
| 200 | +- Port configured via PORT environment variable (defaults to 8443) |
| 201 | +- **Requires SSL certificate and private key files (CERT_FILE and KEY_FILE)** |
| 202 | + |
| 203 | +### STDIO Mode (TRANSPORT=stdio or unset) |
| 204 | +- Uses standard input/output for communication |
| 205 | +- Configuration through environment variables only |
| 206 | +- Requires API_BASE_URL environment variable |
| 207 | +- Suitable for command-line usage |
| 208 | + |
0 commit comments