PaddlePaddle/PaddleOCR · error · ValueError
Unknown provider: {provider}
Error message
Unknown provider: {provider} What it means
ValueError from the paddleocr_mcp __main__ provider dispatch: after handling the appstore and self_hosted branches (and qianfan above), any other --provider value falls into the else and raises 'Unknown provider'. The printed message uses the raw provider string, and async_main catches ValueError, prints it, and exits with code 2.
Source
Thrown at mcp_server/paddleocr_mcp/__main__.py:219
poll_timeout=float(args.aistudio_poll_timeout),
)
elif provider == InferenceProvider.QIANFAN.value:
return create_inference(
model=model,
provider=provider,
base_url=args.qianfan_base_url,
api_key=args.qianfan_api_key,
http_timeout=args.http_timeout,
)
elif provider == InferenceProvider.SELF_HOSTED.value:
return create_inference(
model=model,
provider=provider,
base_url=args.self_hosted_base_url,
http_timeout=args.http_timeout,
)
else:
raise ValueError(f"Unknown provider: {provider}")
async def async_main() -> None:
"""Asynchronous main entry point."""
args = _parse_args()
_validate_args(args)
try:
model = resolve_model(args.model, args.ppocr_source)
except ValueError as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(2)
inference = _create_inference_from_args(args, model)
try:
await inference.start()
View on GitHub (pinned to 2661c7c0ef)
Solutions
- Use one of the exact InferenceProvider values (e.g. appstore, qianfan, self_hosted) — check the enum in paddleocr_mcp for the authoritative list.
- If the provider comes from an environment variable, strip it: os.environ[...].strip().
- Check `--help` output of the mcp server for the allowed choices.
Example fix
// before paddleocr-mcp --provider local Error: Unknown provider: local // after paddleocr-mcp --provider self_hosted
Defensive patterns
Strategy: validation
Validate before calling
from paddleocr_mcp import InferenceProvider # or import from its selection/config module
def provider_valid(provider: str) -> bool:
return (provider or "").strip() in {p.value for p in InferenceProvider} Type guard
from typing import Any
def is_known_provider(value: Any) -> bool:
if isinstance(value, InferenceProvider):
return True
return isinstance(value, str) and value.strip() in {
p.value for p in InferenceProvider
} Try / catch
try:
create_provider(args)
except ValueError as e:
if "Unknown provider" in str(e):
# exit code 2 already set by async_main; log allowed values for the operator
log.error("provider must be one of %s", [p.value for p in InferenceProvider])
raise Prevention
- Source --provider from the InferenceProvider enum values in launcher scripts.
- Strip() environment-derived provider strings before use.
- Add a startup check that fails fast with the allowed list instead of relying on runtime dispatch.
When it happens
Trigger: Starting the MCP server with --provider set to a value not in InferenceProvider (e.g. 'local', 'qianfan ' with whitespace, wrong casing like 'SelfHosted'); a typo on the CLI.
Common situations: CLI flags copied from outdated docs where provider names changed; env var supplying the provider with trailing newline/whitespace.
Related errors
- Unsupported model: {normalized!r}. Supported models: {suppor
- Model {normalized!r} is not supported with qianfan source. S
- Invalid data URL: expected a comma after the MIME type.
- Invalid Base64 input: {e}. Ensure the string is complete and
- The input data is inconsistent with expectations.
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/9144eeb1cfddda3c.
Report an issue: GitHub.