Implementation:1mcp app Agent ServeOptions Auth Flags
| Knowledge Sources | |
|---|---|
| Domains | Security, CLI |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete configuration interface defining CLI flags for enabling OAuth 2.1 authentication, external URL, scope validation, and credential storage on the serve command.
Description
The ServeOptions interface defines the authentication-related CLI flags parsed by yargs and applied to the AgentConfigManager at startup. The `--enable-auth` flag turns on OAuth 2.1 for inbound client authentication. The `--external-url` flag sets the public URL for OAuth redirects. The `--enable-scope-validation` flag enables tag-based scope authorization for template context (ADR-0013). The `--credential-store` flag selects file-based or native credential storage. The `--session-ttl` and `--session-storage-path` flags control session persistence.
Usage
Reference this interface when you need to:
- Enable OAuth 2.1 authentication on the 1MCP runtime
- Configure the external URL for OAuth redirect callbacks
- Enable tag-based scope validation for template context authorization
- Select credential storage backend (file or native OS keychain)
Code Reference
Source Location
- Repository: 1MCP Agent
- File: src/sdk/legacy/commands/serve.ts (L56-100), resolution helpers in src/commands/serve/serveOptions.ts
Signature
export interface ServeOptions {
'enable-auth'?: boolean;
'external-url'?: string;
'enable-scope-validation'?: boolean;
'enable-enhanced-security'?: boolean;
'credential-store'?: 'file' | 'native';
'session-ttl'?: number;
'session-storage-path'?: string;
// ... plus transport, port, host, preset, filter, async loading flags
}
Import
import type { ServeOptions } from '@src/commands/serve/serve.js';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| enable-auth | boolean | No | Enable OAuth 2.1 authentication |
| external-url | string | No | Public URL for OAuth redirects |
| enable-scope-validation | boolean | No | Tag-based scope validation |
| credential-store | 'native' | No | Credential storage backend |
| session-ttl | number | No | Session lifetime in minutes |
Outputs
| Name | Type | Description |
|---|---|---|
| AgentConfig | side effect | Flags applied to AgentConfigManager |
Usage Examples
Enable Authentication via CLI
1mcp serve --enable-auth --external-url https://my-server.com --enable-scope-validation
1mcp serve --enable-auth --credential-store native --session-ttl 60