searxng-mcp-go/docs/LANGUAGE_PARAMETER_RESEARCH.md
XLion 116d460995
fix: correct empty-response retry cancellation, add trust warning, thread ctx into ShouldRetry
- Return context error instead of empty success when retry wait is canceled
- Thread caller context into ShouldRetry so isRetryableError checks ctx.Err()
- Add warning field to SearchResponse JSON and CLI text header for external content
- Add regression test for empty-response retry cancellation
- Update stale docs referencing removed performSearch function
- Fix OUTPUT_FORMAT.md JSON example and gofmt formatting
2026-05-27 02:15:59 +08:00

2.4 KiB

SearXNG Language Parameter Research

Current Behavior

The implementation uses the language parameter end-to-end.

  • MCP schema exposes language
  • SearchArgs.Language maps to language
  • Search execution sends language to SearXNG when the field is non-empty
  • ValidateSearchArgs() rejects invalid language codes

Semantics

  • Empty language means auto mode: the parameter is omitted and SearXNG chooses its default
  • Valid values include codes like en, zh-tw, and ja
  • Invalid values are rejected with a validation error
  • There is no fallback that rewrites invalid input to English

Historical Note

Earlier versions of this project and this document discussed a lang parameter and English fallback behavior. That no longer reflects the codebase.

Reference Points

  • internal/searxng/searcher.go
  • internal/searxng/validation.go
  • mcp.go

Note: The curl examples below use both the lang and language parameters for comparison testing and are for research purposes. The actual code only sends the language parameter and does not use lang.

Query: python programming

curl -s "http://localhost:8888/search?q=python+programming&format=json&lang=en" | jq '[.results[] | {engine, title}]'
curl -s "http://localhost:8888/search?q=python+programming&format=json&language=en" | jq '[.results[] | {engine, title}]'
curl -s "http://localhost:8888/search?q=python+programming&format=json&lang=ja" | jq '[.results[] | {engine, title}]'
curl -s "http://localhost:8888/search?q=python+programming&format=json&language=ja" | jq '[.results[] | {engine, title}]'

Query: artificial intelligence

curl -s "http://localhost:8888/search?q=artificial+intelligence&format=json&lang=en" | jq '[.results[] | {engine, title}]'
curl -s "http://localhost:8888/search?q=artificial+intelligence&format=json&lang=de" | jq '[.results[] | {engine, title}]'
curl -s "http://localhost:8888/search?q=artificial+intelligence&format=json&lang=fr" | jq '[.results[] | {engine, title}]'
curl -s "http://localhost:8888/search?q=artificial+intelligence&format=json" | jq '[.results[] | {engine, title}]'

Reference Points

  • internal/searxng/types.go — SearchArgs struct
  • internal/searxng/searcher.go — search request construction and execution
  • internal/searxng/validation.go — ValidateSearchArgs() language validation
  • mcp.go — MCP tool schema definition