Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1mcp app Agent AgentConfigManager

From Leeroopedia
Knowledge Sources
Domains Configuration, Software_Architecture
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete singleton manager for agent-specific runtime configuration including async loading, lazy loading, auth, rate limiting, and feature flags.

Description

The AgentConfigManager class provides typed access to the `AgentConfig` interface, which defines all runtime behavioral settings: host/port, auth settings (credential store, session TTL, OAuth token TTL), feature flags (configReload, envSubstitution, scopeValidation, clientNotifications, internalTools), async loading policy (enabled, concurrency, retry), and lazy loading policy (cache, preload, fallback). It supports partial updates via deep merge and offers convenience getter methods for frequently accessed properties. The CLI serve command updates this config from yargs-parsed options at startup.

Usage

Import this class when you need to:

  • Check if async loading is enabled (`agentConfig.get('asyncLoading').enabled`)
  • Determine the loading mode branch (async vs sync) at server startup
  • Access auth, rate limit, or feature flag settings from business logic
  • Update configuration at runtime from CLI options (`agentConfig.updateConfig(partial)`)

Code Reference

Source Location

  • Repository: 1MCP Agent
  • File: src/core/server/agentConfig.ts (L37-446)

Signature

export interface AgentConfig {
  host: string;
  port: number;
  externalUrl?: string;
  auth: { credentialStore: 'file' | 'native'; enabled: boolean; sessionTtlMinutes: number; oauthCodeTtlMs: number; oauthTokenTtlMs: number; sessionStoragePath?: string };
  features: { auth: boolean; scopeValidation: boolean; enhancedSecurity: boolean; configReload: boolean; envSubstitution: boolean; sessionPersistence: boolean; clientNotifications: boolean; jsonRpcErrorLogging: boolean; internalTools: boolean; internalToolsList: string[] };
  asyncLoading: { enabled: boolean; notifyOnServerReady: boolean; waitForMinimumServers: number; initialLoadTimeoutMs: number; batchNotifications: boolean; batchDelayMs: number; loadingPolicy: BackendLoadingPolicy };
  lazyLoading: { enabled: boolean; inlineCatalog: boolean; catalogFormat: 'flat' | 'grouped' | 'categorized'; directExpose: string[]; cache: { maxEntries: number; strategy: 'lru'; ttlMs?: number }; preload: { patterns: string[]; keywords: string[] }; fallback: { onError: 'skip' | 'full'; timeoutMs: number } };
  // ... plus admin, templateContext, rateLimit, health, configReload, sessionPersistence
}

export class AgentConfigManager {
  private static instance: AgentConfigManager;
  public static getInstance(): AgentConfigManager;
  public get<K extends keyof AgentConfig>(key: K): AgentConfig[K];
  public updateConfig(updates: Partial<AgentConfig>): void;
  public getUrl(): string;
  public isAuthEnabled(): boolean;
  public isAsyncLoadingEnabled(): boolean;
  public isScopeValidationEnabled(): boolean;
}

Import

import { AgentConfigManager, AgentConfig } from '@src/core/server/agentConfig.js';

I/O Contract

Inputs

Name Type Required Description
updates Partial<AgentConfig> No Partial config to deep-merge into current

Outputs

Name Type Description
get(key) AgentConfig[K] Typed config section
getUrl() string External URL or http://host:port

Usage Examples

Checking Loading Mode

import { AgentConfigManager } from '@src/core/server/agentConfig.js';

const agentConfig = AgentConfigManager.getInstance();
const asyncLoadingEnabled = agentConfig.get('asyncLoading').enabled;

if (asyncLoadingEnabled) {
  // Use setupServerAsync path
} else {
  // Use setupServerSync path
}

Updating from CLI Options

const agentConfig = AgentConfigManager.getInstance();
agentConfig.updateConfig({
  auth: { enabled: true, sessionTtlMinutes: 60 },
  features: { scopeValidation: true },
});

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment