svcs
A Flexible Service Locator
What it is and what it does
svcs is a dependency container that centralizes the registration and acquisition of service instances in Python applications. It supports both dependency injection and service locator patterns without requiring global state, decorators, or function signature changes. The container automatically manages cleanup of acquired services through context managers and provides health checks for monitoring.
The package integrates with popular web frameworks (AIOHTTP, FastAPI, Flask, Pyramid, Starlette) and provides full static type safety when used with a type checker. It reduces boilerplate code for service acquisition and cleanup while maintaining loose coupling between components, which simplifies testing. Recent versions added support for abstract types via PEP 747 and autowiring based on type annotations.
Use it for:
- Manage database connections, API clients, and caches in FastAPI or Flask applications with automatic cleanup per request.
- Implement dependency injection in web frameworks without decorators or global state, improving testability.
- Register multiple implementations of a service interface and switch between them for different environments or test scenarios.
- Add health checks to services for monitoring and observability in production applications.
- Automatically resolve and inject dependencies based on type annotations in function signatures.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
svcs is a dependency container that registers factories for types and provides automatic cleanup and health checks when acquiring service instances in Python applications.
Yes. svcs is actively maintained, production-stable, has no known vulnerabilities, and solves a genuine problem in dependency management for Python web applications. The low install friction and optional static typing make it accessible. It's particularly valuable if you're using FastAPI, Flask, or another supported framework and want to reduce boilerplate around service acquisition and cleanup.
Install
svcs on PyPI
pip
pip install svcsuv
uv add svcspoetry
poetry add svcsInstalling svcs
Before you install
Low friction install with only two lightweight runtime dependencies (attrs and typing-extensions). Active maintenance with a release 32 days ago and recent commits; marked Production/Stable.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install svcs
from svcs import Container
from attrs import define
@define
class Database:
pass
container = Container()
container.register(Database, factory=Database)
db = container.get(Database)
Requires Python 3.10 or later; Python 3.9 support was removed.
Verify before relying
- Whether the framework integrations (AIOHTTP, FastAPI, Flask, Pyramid, Starlette) are included in the base package or require separate installation.
- Performance characteristics when managing large numbers of service instances or complex dependency graphs.
- Whether health checks are automatically invoked or must be explicitly called.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — attrs, typing-extensions |
| Maintenance | actively maintained — 32 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 7,427,821/month — #1,741 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: svcs-26.1.0-py3-none-any.whl
Keywords: aiohttp, dependency injection, fastapi, flask, inversion of control, pyramid, service locator, starlette
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
dependenciesImplements constructor injection for dependency…
permissive · top 15,000 on PyPI
kinkKink is a lightweight dependency injection…
permissive · top 15,000 on PyPI
dependency-injectorDependency Injector is a dependency injection…
permissive · top 5,000 on PyPI
wireupWireup is a type-driven dependency injection…
permissive · top 15,000 on PyPI
slackA dependency injection container that registers…
permissive · top 15,000 on PyPI
simple-diA strictly typed dependency injection library…
permissive · top 15,000 on PyPI
punqPunq is a dependency injection container for…
unclear · top 15,000 on PyPI
injectorInjector is a Python dependency injection…
permissive · top 5,000 on PyPI
injectProvides a lightweight dependency injection…
permissive · top 5,000 on PyPI
rodiRodi is a dependency injection container for…
permissive · top 15,000 on PyPI