In Memory Token Store (store/in_memory.py)

mcp-agent · src/mcp_agent/oauth/store/in_memory.py · python · Apache-2.0
auth, database, testing, lang:python, tag:async

Provides an asynchronous in-memory token store implementation for local development and testing environments.

# Source: https://github.com/lastmile-ai/mcp-agent | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""In-memory token store for local development and testing."""

from __future__ import annotations

import asyncio
from typing import Dict

from .base import TokenStore, TokenStoreKey
from ..records import TokenRecord


class InMemoryTokenStore(TokenStore):
    def __init__(self) -> None:
        self._records: Dict[TokenStoreKey, TokenRecord] = {}
        self._lock = asyncio.Lock()

    async def get(self, key: TokenStoreKey) -> TokenRecord | None:
        async with self._lock:
            record = self._records.get(key)
            if record is None:
                return None
  

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key