Integrations

Integrating with MCP

The Model Context Protocol (MCP) allows Fastino’s Personalization API to plug directly into AI runtimes and agent frameworks — enabling models to retrieve, learn, and update personalized context in real time.


This integration gives any compliant agent the ability to:

  • Retrieve relevant user memories (retrieve_relevant_chunks)

  • Ask semantic questions about users (search_or_ask)

  • Update contextual memory after an interaction (update_memory)

Overview

MCP is a lightweight protocol for connecting AI models to external tools and APIs.
By registering the Fastino Personalization API as an MCP toolset, your agents can dynamically recall user context, ground responses, and continuously improve from feedback.

Fastino exposes three MCP tools for user-level personalization:

Tool

Description

retrieve_relevant_chunks

Retrieve the most relevant snippets of user memory for grounding

search_or_ask

Ask natural-language questions about a user’s profile

update_memory

Send new observations or updates to the user’s world model

Prerequisites

Before integrating:

  • You have a valid Fastino API key

  • MCP runtime installed or accessible (e.g., OpenAI MCP, Anthropic’s Tool Use runtime, or custom agent shell)

  • Python or Node.js environment configured for tool registration

  • At least one user registered via /register

Configuration

You can expose Fastino’s API to an MCP agent by registering it in your tool manifest or connector script.

Example: MCP Tool Manifest

{
  "tools": [
    {
      "name": "retrieve_relevant_chunks",
      "description": "Retrieve top-k relevant snippets of user context.",
      "schema": {
        "type": "object",
        "properties": {
          "user_id": {"type": "string"},
          "conversation": {"type": "array"},
          "top_k": {"type": "integer", "default": 5}
        },
        "required": ["user_id"]
      }
    },
    {
      "name": "search_or_ask",
      "description": "Ask a natural-language question about the user's memory.",
      "schema": {
        "type": "object",
        "properties": {
          "user_id": {"type": "string"},
          "question": {"type": "string"}
        },
        "required": ["user_id", "question"]
      }
    },
    {
      "name": "update_memory",
      "description": "Update the user's profile or ingest new signals.",
      "schema": {
        "type": "object",
        "properties": {
          "user_id": {"type": "string"},
          "content": {"type": "string"}
        },
        "required": ["user_id", "content"]
      }
    }
  ]
}

Example Integration (Python)

The following snippet demonstrates how an MCP agent can call Fastino tools directly during conversation.

from mcp_client import MCPClient
import requests

FASTINO_API = "https://api.fastino.ai/"
FASTINO_KEY = "pk-..."
HEADERS = {"Authorization": f"x-api-key: {FASTINO_KEY}", "Content-Type": "application/json"}

# Initialize MCP client
client = MCPClient()

# Define Fastino-backed tools
@client.tool("retrieve_relevant_chunks")
def retrieve_relevant_chunks(user_id: str, conversation: list, top_k: int = 5):
    payload = {"user_id": user_id, "conversation": conversation, "top_k": top_k}
    r = requests.post(f"{FASTINO_API}/chunks", json=payload, headers=HEADERS)
    return r.json()

@client.tool("search_or_ask")
def search_or_ask(user_id: str, question: str):
    payload = {"user_id": user_id, "question": question}
    r = requests.post(f"{FASTINO_API}/query", json=payload, headers=HEADERS)
    return r.json()

@client.tool("update_memory")
def update_memory(user_id: str, content: str):
    payload = {
        "user_id": user_id,
        "source": "mcp_runtime",
        "documents": [
            {"doc_id": "doc_auto", "kind": "note", "title": "runtime update", "content": content}
        ]
    }
    r = requests.post(f"{FASTINO_API}/ingest", json=payload, headers=HEADERS)
    return r.json()

if __name__ == "__main__":
    client.run()

Example Conversation Flow

  1. User asks: “When does Ash usually take meetings?”

  2. MCP runtime calls Fastino’s search_or_ask tool:

    {
      "user_id": "usr_42af7c",
      "question": "When does Ash prefer to schedule meetings?"
    }
  3. Fastino responds:

    {
      "answer": "Ash prefers meetings after 1 PM PT, following morning focus blocks."
    }
  4. The agent incorporates this directly into its reasoning or response.

Common Patterns

Pattern

Tool Used

Description

Grounding model prompts

retrieve_relevant_chunks

Retrieve memory snippets before generating responses

Personalized reasoning

search_or_ask

Ask clarifying questions about user goals or habits

Memory updates

update_memory

Log new insights or corrections automatically

Feedback loop

update_memory + query

Store feedback and confirm updated understanding

Authentication

Each MCP tool must authenticate via the same bearer token scheme as standard Fastino API calls.

Example header:

Authorization: x-api-key: pk-...
Content-Type: application/json

We recommend using workspace-scoped keys for security and rotating them every 90 days.

Error Handling

Fastino MCP tools return standardized JSON errors consistent with the REST API.

{
  "error": {
    "code": "USER_NOT_FOUND",
    "message": "No user found with ID usr_42af7c"
  }
}

MCP runtimes should catch and surface these gracefully within the conversation trace.

Best Practices

  • Register the tools at runtime initialization, not per turn.

  • Cache MCP tool responses for ephemeral session performance.

  • Use consistent user_id across all agents in a workspace.

  • Implement the update_memory tool for long-running conversations to maintain continuity.

  • Log and version memory updates for transparency.

  • Restrict MCP tokens to read/write scopes depending on your agent type.

Example Use Case: Personalized Assistant

A chat agent can use Fastino’s MCP integration to remember preferences and style:

  • search_or_ask → learns “User prefers concise async replies.”

  • update_memory → saves new information like “Moved meetings to 2 PM.”

  • retrieve_relevant_chunks → grounds next message with past context.

Result: the agent behaves consistently across sessions, mirroring tone and timing preferences dynamically.

Summary

Integrating Fastino with MCP gives your agents true memory and adaptive reasoning — bridging static LLM responses with personalized, evolving context.

By registering Fastino’s personalization tools within MCP, your agents gain the ability to recall, learn, and refine their understanding of every user in real time.

Next, continue to Integrating with LlamaIndex to learn how to connect Fastino’s personalization layer to a local or enterprise retrieval pipeline.

On this page