Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/huge-ducks-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@iqai/mcp-discord": patch
---

Adds coerce to convert string to number for env vars
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ All configuration is now handled via the `src/config.ts` file, which supports bo
| `DEFAULT_RATE_LIMIT_SECONDS` | number | `2` | Rate limit (seconds) for sampling requests per user. |
| `DEFAULT_MESSAGE_CHUNK_SIZE` | number | `2000` | Max message chunk size for sampling responses. |
| `RESPOND_TO_MENTIONS_ONLY` | boolean | `true` | Only respond to messages that mention the bot. |
| `SAMPLING_DEFAULT_TIMEOUT` | number | — | Timeout (milliseconds) for sampling requests. |
| `SAMPLING_REACTION_TIMEOUT` | number | — | Timeout (milliseconds) for sending reactions to Discord. |
| `BLOCK_DMS` | boolean | `true` | Block direct messages to the bot. |
| `BLOCKED_GUILDS` | string | `""` | Comma-separated list of guild IDs to block. |
| `BANNED_USERS` | string | `""` | Comma-separated list of user IDs to ban. |
Expand All @@ -126,6 +128,8 @@ HTTP_PORT=3000
DEFAULT_RATE_LIMIT_SECONDS=5
DEFAULT_MESSAGE_CHUNK_SIZE=1500
RESPOND_TO_MENTIONS_ONLY=true
SAMPLING_DEFAULT_TIMEOUT=5000
SAMPLING_REACTION_TIMEOUT=3000
BLOCK_DMS=true
BLOCKED_GUILDS="123456789,987654321"
BANNED_USERS="111111111,222222222"
Expand All @@ -137,7 +141,7 @@ REACTION_FALLBACK_EMOJI="👍"
**Command-line arguments:**

```bash
node build/index.js --config "your_discord_bot_token" --sampling --transport http --port 3000 --rate-limit 5 --message-chunk-size 1500 --mentions-only --block-dms --blocked-guilds "123,456" --banned-users "111,222" --reaction-timeout 3000 --enable-reaction-sampling --reaction-fallback-emoji "👍"
node build/index.js --config "your_discord_bot_token" --sampling --transport http --port 3000 --rate-limit 5 --message-chunk-size 1500 --mentions-only --sampling-default-timeout 5000 --sampling-reaction-timeout 3000 --block-dms --blocked-guilds "123,456" --banned-users "111,222" --reaction-timeout 3000 --enable-reaction-sampling --reaction-fallback-emoji "👍"
```

If both are provided, command-line arguments take precedence.
Expand Down
10 changes: 5 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ const envSchema = z.object({
.string()
.optional()
.transform((val) => (val ? Number.parseInt(val, 10) : 8080)),
DEFAULT_RATE_LIMIT_SECONDS: z
DEFAULT_RATE_LIMIT_SECONDS: z.coerce
.number()
.optional()
.default(2)
.describe('used in sampling, when sampling is enabled'),
DEFAULT_MESSAGE_CHUNK_SIZE: z
DEFAULT_MESSAGE_CHUNK_SIZE: z.coerce
.number()
.optional()
.default(2000)
Expand All @@ -32,11 +32,11 @@ const envSchema = z.object({
.optional()
.default(true)
.describe('Only respond to messages that mention the bot'),
SAMPLING_DEFAULT_TIMEOUT: z
SAMPLING_DEFAULT_TIMEOUT: z.coerce
.number()
.optional()
.describe('A timeout (in milliseconds) for this request'),
SAMPLING_REACTION_TIMEOUT: z
SAMPLING_REACTION_TIMEOUT: z.coerce
.number()
.optional()
.describe('A timeout for sending reactions to discord'),
Expand All @@ -55,7 +55,7 @@ const envSchema = z.object({
.optional()
.default('')
.describe('Comma-separated list of user IDs to ban'),
REACTION_TIMEOUT_MS: z
REACTION_TIMEOUT_MS: z.coerce
.number()
.optional()
.default(3000)
Expand Down