MCP ExplorerExplorer

Contextbase Py

@imfeniljikadaraon a year ago
1 MIT
FreeCommunity
AI Systems
A python sdk for interacting with the contextbase mcp api

Overview

What is Contextbase Py

contextbase-py is a Python SDK designed for interacting with the ContextBase MCP API, providing a simple key-value memory storage service with authentication and search capabilities.

Use cases

Use cases for contextbase-py include user session management, temporary data storage, caching frequently accessed data, and implementing search functionalities in applications.

How to use

To use contextbase-py, install it via pip with ‘pip install contextbase-py’. Initialize the Context object with the base URL, authenticate using signup and login methods, and perform memory operations such as set, get, list, search, and delete.

Key features

Key features of contextbase-py include user authentication, memory storage with optional time-to-live (TTL), search functionality for memories, and the ability to list all stored memories.

Where to use

contextbase-py can be used in various fields such as web applications, data storage solutions, and any project requiring a simple key-value store with search capabilities.

Content

contextbase-py version

ContextBase Python SDK

A Python SDK for interacting with the ContextBase MCP API, simple key-value memory storage service with authentication and search capabilities.

Installation

pip install contextbase-py

Usage

Initialization

from contextbase import Context

ctx = Context(base_url='https://contextbase.onrender.com')

Authentication

signup_token = ctx.signup('[email protected]', 'password')

login_token = ctx.login('[email protected]', 'password')

ctx.set_token('your-auth-token')

Memory Operations

ctx.set('myKey', 'myValue')

ctx.set('temporaryKey', 'temporaryValue', 3600)  # 1 hour TTL
ctx.set('temporaryKey', 'temporaryValue')  # Without TTL

memory = ctx.get('myKey')

all_memories = ctx.list()

search_results = ctx.search('queryString')

ctx.delete('myKey')

API Reference

Constructor

Context(
    base_url: str,
    token: str = None  # Optional initially, required for memory operations
)

Methods

Method Parameters Return Type Description
set_token token: str None Sets the authentication token
signup email: str, password: str str Creates a new user account and returns a token
login email: str, password: str str Authenticates user and returns a token
set key: str, value: str, ttl: int = None dict Stores a memory with optional TTL (in seconds)
get key: str dict Retrieves a memory by key
list None list Lists all memories
search query: str list Searches memories by query string
delete key: str dict Deletes a memory by key

License

MIT

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers