Command-Line Interface (CLI)
Relevant source files
The following files were used as context for generating this wiki page:The python-sdk project utilizes several command-line interfaces (CLIs) to manage its ecosystem, from development and testing to running servers and example clients. The primary tool for executing these commands is uv, a fast Python package installer and resolver.
This document outlines the various CLI entry points available in the project. These include an interactive client for communicating with MCP servers, commands for launching server components, and a suite of tools for maintaining code quality and running tests during development.
Example MCP Client CLI
The project includes an example interactive CLI client that demonstrates how to connect to and interact with an MCP server that requires OAuth 2.0 authentication.
Sources: examples/clients/simple-auth-client/README.md
Configuration
The client's behavior is configured using environment variables before execution.
| Variable | Description | Default |
|---|---|---|
MCP_SERVER_PORT | The port of the target MCP server. | 8000 |
MCP_TRANSPORT_TYPE | The transport protocol to use. Can be streamable_http or sse. | streamable_http |
Sources: examples/clients/simple-auth-client/README.md:43-44
Usage and Commands
To run the client, use the uv run command from within the client's directory.
# Run with default settings
uv run mcp-simple-auth-client
# Run with custom port and SSE transport
MCP_SERVER_PORT=3001 MCP_TRANSPORT_TYPE=sse uv run mcp-simple-auth-client
Sources: examples/clients/simple-auth-client/README.md:21-26
Upon launching, the client initiates an OAuth flow by providing a URL for browser-based authorization. Once connected, it presents an interactive prompt.
The following diagram illustrates the client's operational flow.
The available interactive commands are:
| Command | Description | Example |
|---|---|---|
list | Lists the tools available on the connected MCP server. | mcp> list |
call <tool_name> [args] | Calls a specific tool with optional JSON arguments. | mcp> call echo {"text": "Hello!"} |
quit | Exits the interactive client. | mcp> quit |
Sources: examples/clients/simple-auth-client/README.md:32-34
Server-Side CLI
The project provides CLI commands to run the necessary server components for the example authentication setup: a dedicated Authorization Server (AS) and the MCP-enabled Resource Server (RS).
Sources: examples/servers/simple-auth/README.md
Running Servers
The servers are launched using uv run from the examples/servers/simple-auth directory.
This diagram shows how the CLI commands launch the distinct server processes and the client, and how these components interact.
Server Configuration Flags
The Resource Server (MCP Server) can be configured with command-line flags.
| Flag | Description | Example |
|---|---|---|
--port | Sets the port for the server to listen on. | --port=8001 |
--auth-server | The URL of the Authorization Server. | --auth-server=http://localhost:9000 |
--transport | The transport protocol to enable. | --transport=streamable-http |
--oauth-strict | Enforces strict RFC 8707 resource validation. | --oauth-strict |
Sources: examples/servers/simple-auth/README.md:19-23
Development Workflow CLI
The development process relies heavily on CLI commands managed by uv for dependency management, code quality assurance, and testing.
Sources: CONTRIBUTING.md, CLAUDE.md
Setup and Dependency Management
Initial project setup and dependency synchronization are handled by uv.
| Command | Description |
|---|---|
uv sync --frozen --all-extras --dev | Installs all project dependencies, including development and optional extras, from the lockfile. |
uv tool install pre-commit ... | Installs the pre-commit hook runner. |
uv lock --resolution lowest-direct | Updates the dependency lockfile after a change in pyproject.toml. |
Sources: CONTRIBUTING.md:14-19, RELEASE.md:6
Code Quality and Testing
A standardized set of CLI commands ensures code consistency and correctness. These are typically run before committing code.
The following diagram shows the recommended development workflow using these CLI tools.
Sources: CONTRIBUTING.md:27-40, CLAUDE.md:38-51
| Command | Description | Source File |
|---|---|---|
uv run ruff format . | Formats Python code according to project style. | CONTRIBUTING.md:39 |
uv run ruff check . | Lints the codebase for potential errors and style violations. | CONTRIBUTING.md:38 |
uv run pyright | Performs static type checking on the codebase. | CONTRIBUTING.md:35 |
uv run pytest | Executes the automated test suite. | CONTRIBUTING.md:31 |
pre-commit run --all-files | Runs all configured pre-commit hooks against all files. | CONTRIBUTING.md:43 |
Sources: CONTRIBUTING.md:27-44, CLAUDE.md:38-51