config
- class arxiv_query_mcp.config.Config(arxiv_api_url='https://export.arxiv.org/api/query', arxiv_abs_base='https://arxiv.org/abs', arxiv_html_base='https://arxiv.org/html', arxiv_pdf_base='https://arxiv.org/pdf', request_timeout=30.0, max_fetch_chars=10000, max_pdf_bytes=30000000, cache_dir='', l1_ttl=300.0, l2_ttl=14400.0, negative_ttl=60.0, l1_maxsize=256, rate_limit_period=3.0, max_concurrency=2, max_retries=4, backoff_base=1.0, backoff_max=30.0, user_agent=<factory>, cache_enabled=True, rate_limit_enabled=True, skill_url='https://raw.githubusercontent.com/LWaetzig/arxiv-query-mcp/main/src/arxiv_query_mcp/skills/arxiv-query-mcp/SKILL.md', s2_api_url='https://api.semanticscholar.org', s2_api_key='', s2_rate_limit_period=1.0)[source]
Bases:
objectImmutable runtime configuration for the arXiv MCP server.
All fields have sensible defaults so no environment variables or files are required. Instantiate once at module level and share across tools.
Use
from_env()to create an instance that respects environment-variable overrides, which is what the server lifespan does.- Variables:
arxiv_api_url (str) – Base URL for the arXiv Atom API.
arxiv_abs_base (str) – Base URL for arXiv abstract pages.
arxiv_html_base (str) – Base URL for arXiv HTML paper pages.
arxiv_pdf_base (str) – Base URL for arXiv PDF download pages.
request_timeout (float) – Seconds before an outgoing HTTP request times out.
max_fetch_chars (int) – Maximum characters per page returned by arxiv_fetch_paper_text; callers read further pages via
offset.max_pdf_bytes (int) – Largest PDF (in bytes) that arxiv_fetch_paper_text will parse when a paper has no HTML version.
0disables the PDF fallback.cache_dir (str) – Directory for the persistent L2 disk cache. Empty string means “use the platform default via platformdirs or a temp dir”.
l1_ttl (float) – Time-to-live (seconds) for in-memory L1 cache entries.
l2_ttl (float) – Time-to-live (seconds) for disk L2 cache entries.
negative_ttl (float) – TTL (seconds) for empty / not-found cache entries.
l1_maxsize (int) – Maximum number of entries kept in the L1 in-memory cache.
rate_limit_period (float) – Minimum seconds between consecutive arXiv requests (cross-process, enforced via diskcache).
max_concurrency (int) – Maximum simultaneous in-process HTTP requests (asyncio.Semaphore bound).
max_retries (int) – Maximum number of attempts made by resilient_get before re-raising the final exception.
backoff_base (float) – Initial exponential-backoff interval in seconds.
backoff_max (float) – Maximum exponential-backoff interval in seconds.
user_agent (str) – User-Agent header sent with every outgoing request.
cache_enabled (bool) – When False the cache layer is a transparent pass-through.
rate_limit_enabled (bool) – When False rate limiting and the semaphore are skipped.
skill_url (str) – URL of the agent
SKILL.mdthat explains how and when to use this server. It is advertised to clients in the server instructions. An empty string disables the notice.s2_api_url (str) – Base URL of the Semantic Scholar API, used by arxiv_related_papers.
s2_api_key (str) – Optional Semantic Scholar API key sent as
x-api-key. Without one, requests share Semantic Scholar’s public pool and are throttled more often.s2_rate_limit_period (float) – Minimum seconds between Semantic Scholar requests (cross-process).
- arxiv_api_url: str = 'https://export.arxiv.org/api/query'
- arxiv_abs_base: str = 'https://arxiv.org/abs'
- arxiv_html_base: str = 'https://arxiv.org/html'
- arxiv_pdf_base: str = 'https://arxiv.org/pdf'
- request_timeout: float = 30.0
- max_fetch_chars: int = 10000
- max_pdf_bytes: int = 30000000
- cache_dir: str = ''
- l1_ttl: float = 300.0
- l2_ttl: float = 14400.0
- negative_ttl: float = 60.0
- l1_maxsize: int = 256
- rate_limit_period: float = 3.0
- max_concurrency: int = 2
- max_retries: int = 4
- backoff_base: float = 1.0
- backoff_max: float = 30.0
- user_agent: str
- cache_enabled: bool = True
- rate_limit_enabled: bool = True
- skill_url: str = 'https://raw.githubusercontent.com/LWaetzig/arxiv-query-mcp/main/src/arxiv_query_mcp/skills/arxiv-query-mcp/SKILL.md'
- s2_api_url: str = 'https://api.semanticscholar.org'
- s2_api_key: str = ''
- s2_rate_limit_period: float = 1.0
- property resolved_cache_dir: str
Return the effective cache directory, resolving the platform default.
- Returns:
An absolute path string. When
cache_diris non-empty it is returned as-is; otherwise the platform user-cache directory (viaplatformdirs) is used, falling back to a subdirectory of the system temp directory ifplatformdirsis unavailable.
- classmethod from_env()[source]
Construct a
Configwith environment-variable overrides.Each field can be overridden by a corresponding environment variable. Unset variables fall back to the field’s default value.
- Environment variables recognised:
ARXIV_API_URL,ARXIV_MCP_CACHE_DIR,ARXIV_MCP_L1_TTL,ARXIV_MCP_L2_TTL,ARXIV_MCP_NEGATIVE_TTL,ARXIV_MCP_L1_MAXSIZE,ARXIV_MCP_RATE_LIMIT_PERIOD,ARXIV_MCP_MAX_CONCURRENCY,ARXIV_MCP_MAX_RETRIES,ARXIV_MCP_BACKOFF_BASE,ARXIV_MCP_BACKOFF_MAX,ARXIV_MCP_USER_AGENT,ARXIV_MCP_CACHE_ENABLED,ARXIV_MCP_RATE_LIMIT_ENABLED,ARXIV_MCP_REQUEST_TIMEOUT,ARXIV_MCP_MAX_FETCH_CHARS,ARXIV_MCP_MAX_PDF_BYTES,ARXIV_MCP_SKILL_URL,ARXIV_MCP_S2_API_URL,ARXIV_MCP_S2_API_KEY,ARXIV_MCP_S2_RATE_LIMIT_PERIOD.
- Returns:
A fully populated, immutable
Configinstance.- Raises:
ValueError – If a numeric variable is set to a non-numeric value. The message names the offending variable.
- Return type:
Config