Skip to main content
Glama
jezweb

Australian Postcodes MCP Server

accessors.py1.52 kB
"""Pathable accessors module""" from contextlib import contextmanager from typing import Any from typing import Dict from typing import Hashable from typing import Iterator from typing import List from typing import Mapping from typing import Union class BaseAccessor: """Base accessor.""" def stat(self, parts: List[Hashable]) -> Dict[str, Any]: raise NotImplementedError def keys(self, parts: List[Hashable]) -> Any: raise NotImplementedError def len(self, parts: List[Hashable]) -> int: raise NotImplementedError @contextmanager def open( self, parts: List[Hashable] ) -> Iterator[Union[Mapping[Hashable, Any], Any]]: raise NotImplementedError class LookupAccessor(BaseAccessor): """Accessor for object that supports __getitem__ lookups""" def __init__(self, lookup: Mapping[Hashable, Any]): self.lookup = lookup def stat(self, parts: List[Hashable]) -> Dict[str, Any]: raise NotImplementedError def keys(self, parts: List[Hashable]) -> Any: with self.open(parts) as d: return d.keys() def len(self, parts: List[Hashable]) -> int: with self.open(parts) as d: return len(d) @contextmanager def open( self, parts: List[Hashable] ) -> Iterator[Union[Mapping[Hashable, Any], Any]]: content = self.lookup for part in parts: content = content[part] try: yield content finally: pass

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jezweb/australian-postcodes-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server