[Bug] [BanyanDB] MCP server ignores .env values and silently accepts malformed numeric/TRANSPORT settings
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- node.js, typescript
- Área
- backend
Línea de trabajo
Start in mcp/src/config.ts and mcp/src/index.ts, where configuration is read and .env is loaded; then inspect the MCP tests and docs/operation/mcp/setup.md mentioned in the issue. Reproduce the three cases from the issue and check how the existing MCP_PORT range validation reports errors. Done means .env values are applied, malformed numeric values and unsupported TRANSPORT values fail clearly, and tests cover each case; a pull request is already open.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Search before asking
- I had searched in the issues and found no similar issues.
Apache SkyWalking Component
BanyanDB (apache/skywalking-banyandb)
What happened
While setting up the BanyanDB MCP server (mcp/, main at adc78b88) I found three config problems. All are silent: the server starts, but with values the user didn't ask for.
- Values in
.envare ignored.src/index.tscallsdotenv.config()in its body, butsrc/config.tsreadsprocess.envat module load, and ES module imports run first. By the time.envis loaded, every exported config value is already fixed. - Numeric settings are parsed leniently.
parseIntstops at the first non-digit, so units or typos are cut off without an error:MCP_MAX_BODY_BYTES=1MiB→ 1 byte,MCP_RATE_LIMIT_WINDOW_MS=60s→ 60 ms,MCP_PORT=3000abc→ 3000. TRANSPORTisn't validated.index.tsonly checksTRANSPORT === 'http', soHTTP,Httpor a typo silently falls back to stdio.
What you expected to happen
Values from .env are applied, and invalid values fail at startup with a clear error. The code already does this for an out-of-range MCP_PORT and for values <= 0, so a value like "1MiB" or "HTTP" should be rejected the same way instead of being silently changed.
How to reproduce
In mcp/ on main (adc78b88):
# problems 2 and 3
cat > _check1.mts <<'EOF'
const c = await import('./src/config.ts');
console.log({ MCP_PORT: c.MCP_PORT, MCP_MAX_BODY_BYTES: c.MCP_MAX_BODY_BYTES, MCP_RATE_LIMIT_WINDOW_MS: c.MCP_RATE_LIMIT_WINDOW_MS, TRANSPORT: c.TRANSPORT });
EOF
MCP_PORT=3000abc MCP_MAX_BODY_BYTES=1MiB MCP_RATE_LIMIT_WINDOW_MS=60s TRANSPORT=HTTP npx tsx _check1.mts
Output:
{ MCP_PORT: 3000, MCP_MAX_BODY_BYTES: 1, MCP_RATE_LIMIT_WINDOW_MS: 60, TRANSPORT: 'HTTP' }
# problem 1 (same import order as src/index.ts)
printf 'MCP_PORT=4555\nTRANSPORT=http\n' > /tmp/test.env
cat > _check2.mts <<'EOF'
import dotenv from 'dotenv';
import { MCP_PORT, TRANSPORT } from './src/config.ts';
dotenv.config({ path: '/tmp/test.env', quiet: true });
console.log({ config: { MCP_PORT, TRANSPORT }, env: { MCP_PORT: process.env.MCP_PORT, TRANSPORT: process.env.TRANSPORT } });
EOF
npx tsx _check2.mts
Output:
{ config: { MCP_PORT: 3000, TRANSPORT: 'stdio' }, env: { MCP_PORT: '4555', TRANSPORT: 'http' } }
Anything else
Happens every time. A possible fix, contained to mcp/src:
- load .env before config.ts is evaluated (e.g.
import 'dotenv/config'as the first import in index.ts, or call dotenv.config() at the top of config.ts); - parse integers strictly (the whole string must be digits) in parsePositiveInteger and for MCP_PORT;
- accept only stdio / http for TRANSPORT (case-insensitive) and fail otherwise;
- unit tests for each case, and a note about .env in docs/operation/mcp/setup.md.
Related history: the review of apache/skywalking-banyandb#1010 noted that a non-numeric MCP_PORT becomes NaN and that the docs mentioned streamable-http while the code only accepts http; #1036 then added the MCP_PORT range check. The cases above (partial numbers like "3000abc"/"1MiB", "HTTP" in a different case, and .env being loaded after config.ts) are still open on main.
Are you willing to submit a pull request to fix on your own?
- Yes I am willing to submit a pull request on my own!
Code of Conduct
- I agree to follow this project's Code of Conduct
- Lenguaje dominante
- Java
- Estrellas
- 25k
- Forks
- 6.6k
- Merge medio
- 12 h 57 min
- PR fusionados (30 d)
- 46
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/skywalking
-
[Bug] [BanyanDB] MCP HTTP server rejects a lowercase "bearer" Authorization schemePosiblemente ocupada @UchihaIthachi la tomó hace 2 días. Abiertobug database
apache/skywalking#14199 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Bug] Standalone multi-group Measure aggregation returns one row per groupPosiblemente ocupada @hanahmily la tomó hace 3 días. Abiertobug database
apache/skywalking#14198 · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
[Bug] BanyanDB trace block metadata format changed in 0.11 without a file format version bumpPosiblemente ocupada @hanahmily la tomó hace 13 días. Abiertobug database
apache/skywalking#14169 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
chore CLI database
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
apache/skywalking#14168 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BanyanDB] Stream write callback reports success for events it did not storeQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
apache/skywalking#14158 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/skywalking
Issues similares
-
Document and enforce pull request review guidelinesPosiblemente ocupada @dashorst la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
`Time.at(t, in: nil)` returns UTC instead of the local time (or the time zone of `t`), unlike CRubyAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
hermes-queue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
chrisalunlloyd2-sudo/mindpalace#349 ·
Los mantenedores suelen responder en 1 día
-
Retry-After parser accepts invalid delay-seconds valuesPosiblemente ocupada @Dhruvraj-Rana la tomó hoy. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
open-telemetry/opentelemetry-java#9018 ·
Los mantenedores suelen responder en 2 días
-
dropwizard-testing: DAOTest.inTransaction leaves the transaction open when an Error is thrownAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dropwizard/dropwizard#11410 ·
Los mantenedores suelen responder en 1 día