OpenNotebook MCP Multitenant Proxy Server
This repository contains a Model Context Protocol (MCP) server that actsas a secure, multi-tenant proxy between an AI Assistant and theOpenNotebook backend API. It exposes 81 MCP tools covering 14 resourcedomains with full CRUD, search, chat, podcast, and command management.
โจ Features
- ๐ Identity Passthrough โ Extracts the
Authorization: Bearer <token>header from incoming HTTP requests and forwards it to the OpenNotebook APIwithout server-side authentication. - ๐ฅ Multi-Tenancy โ Uses Python
contextvarsto maintain thread-safeuser identity isolation, ensuring all AI-driven actions are scoped tothe authenticated user's permissions. - ๐ Full OpenNotebook Coverage โ 81 tools mapped to OpenNotebook APIendpoints across 14 resource domains.
- โก TOON Optimization โ Bulk list responses are automatically compressedusing TOON (Token-Optimized Object Notation) to reduce token consumptionand maximize context window efficiency.
- ๐ Efficient Gets โ GET responses return only commonly used fields bydefault. Full objects are available via an
include_all_fieldsflag. - ๐งช Comprehensive Testing โ 109 automated tests covering all tooldomains, run via the test runner pipeline.
- ๐ท๏ธ Tool Annotations โ All tools expose standard MCP ToolAnnotations hints (readOnlyHint, destructiveHint, idempotentHint, openWorldHint). The tags field carries grouping metadata (basic/primary/advanced + opennotebook).
๐ง Environment Variables
| Variable | Required | Description |
|---|---|---|
OPENNOTEBOOK_BASE_URL |
Yes | Docker-internal URL of the OpenNotebook API |
MCP_SERVER_PORT |
Yes | Port number the MCP server listens on |
ALLOW_ALL_AGGREGATE |
No | When true, aggregate listing tools honor the include_all_fields parameter. When false (default), the parameter is silently forced to False for aggregate list operations. |
IS_STATEFUL |
No | When true, uses stateful Streamable HTTP with session tracking. When false (default), uses stateless mode. |
๐ฆ Installation & Local Development
- Ensure you have Python 3.12+ installed.
- Install dependencies:
pip install fastmcp httpx pydantic uvicorn toon-mcp-server - Run the server:
export OPENNOTEBOOK_BASE_URL=http://localhost:5055 export MCP_SERVER_PORT=80 python -m src.main
๐ณ Docker Deployment
Build and run the server using Docker:
docker build -t opennotebook-mcp:latest .
docker run -d --name opennotebook-mcp \
-e OPENNOTEBOOK_BASE_URL="http://opennotebook-app:5055" \
-e MCP_SERVER_PORT=80 \
opennotebook-mcp:latest
The MCP server serves at http://opennotebook-mcp:80/mcp(Streamable HTTP).
โ ๏ธ Important Notes
- ๐
include_all_fieldsโ Theinclude_all_fieldsparameter (availableon allget_*andlist_*tools) controls whether all available fieldsare included in responses. Defaults toFalsefor performance; set toTrueonly when additional fields are needed. - โก TOON Compression โ All bulk list responses are automaticallycompressed using TOON to reduce token consumption by 30โ60%.
- ๐ Required Fields & Defaults โ Each
create_*tool requires specifickey fields. All other fields default to empty strings or reasonable values.The owner field is automatically set to the authenticated user for mostresources.
๐ ๏ธ API Tool Mapping
The server implements 81 MCP tools organized into the following categories:
๐ Notebooks (9 tools)
check_server_statusโ Check the health and status of the OpenNotebook backend APIlist_all_notebooksโ List all notebook recordsget_notebook_by_idโ Get a single notebook by IDcreate_notebookโ Create a new notebookupdate_notebookโ Update an existing notebookdelete_notebook_by_idโ Delete a notebook by IDget_notebook_delete_previewโ Get a preview of what will be deletedadd_source_to_notebookโ Add an existing source to a notebookremove_source_from_notebookโ Remove a source from a notebooklist_recently_viewedโ List recently viewed items
๐ Notes (5 tools)
list_all_notesโ List all note recordsget_note_by_idโ Get a single note by IDcreate_noteโ Create a new noteupdate_noteโ Update an existing notedelete_note_by_idโ Delete a note by ID
๐ Sources (8 tools)
list_all_sourcesโ List all source recordsget_source_by_idโ Get a single source by IDcreate_sourceโ Create a new source (link or text type)update_sourceโ Update an existing sourcedelete_source_by_idโ Delete a source by IDget_source_statusโ Get processing status for a sourceretry_source_processingโ Retry processing for a failed sourcelist_source_insightsโ List all insights for a sourcecreate_source_insightโ Start insight generation for a source
๐ก Insights (4 tools)
get_insight_by_idโ Get a single insight by IDdelete_insight_by_idโ Delete an insight by IDsave_insight_as_noteโ Convert an insight to a notelist_source_insightsโ List insights for a source
๐ Search & Settings (4 tools)
search_knowledge_baseโ Search the knowledge baseask_knowledge_base_simpleโ Ask the knowledge base a questionget_settingsโ Get all application settingsupdate_settingsโ Update application settings
๐ค Models (5 tools)
list_all_modelsโ List all configured modelscreate_modelโ Create a new model configurationdelete_model_by_idโ Delete a model by IDget_default_modelsโ Get default model assignmentsupdate_default_modelsโ Update default model assignments
๐ Transformations (8 tools)
list_all_transformationsโ List all transformation recordsget_transformation_by_idโ Get a single transformation by IDcreate_transformationโ Create a new transformationupdate_transformationโ Update an existing transformationdelete_transformation_by_idโ Delete a transformation by IDexecute_transformationโ Execute a transformation on input textget_default_transformation_promptโ Get the default promptupdate_default_transformation_promptโ Update the default prompt
๐งฉ Embedding (3 tools)
embed_contentโ Embed content for vector searchstart_embedding_rebuildโ Start a background rebuild jobget_rebuild_statusโ Get rebuild operation status
๐ฌ Chat (7 tools)
list_chat_sessionsโ List chat sessions for a notebookcreate_chat_sessionโ Create a new chat sessionget_chat_sessionโ Get a chat session with messagesupdate_chat_sessionโ Update a chat sessiondelete_chat_sessionโ Delete a chat sessionexecute_chatโ Execute a chat requestbuild_chat_contextโ Build notebook context
๐ Source Chat (5 tools)
create_source_chat_sessionโ Create a source chat sessionlist_source_chat_sessionsโ List source chat sessionsget_source_chat_sessionโ Get a source chat sessionupdate_source_chat_sessionโ Update a source chat sessiondelete_source_chat_sessionโ Delete a source chat session
๐๏ธ Podcasts (6 tools)
generate_podcastโ Generate a podcast episodeget_podcast_job_statusโ Get podcast job statuslist_podcast_episodesโ List all podcast episodesget_podcast_episodeโ Get a specific episoderetry_podcast_episodeโ Retry a failed episodedelete_podcast_episodeโ Delete a podcast episode
๐ฌ Episode Profiles (6 tools)
list_episode_profilesโ List all episode profilesget_episode_profileโ Get a profile by namecreate_episode_profileโ Create a new episode profileupdate_episode_profileโ Update an episode profiledelete_episode_profileโ Delete an episode profileduplicate_episode_profileโ Duplicate an episode profile
๐ฃ๏ธ Speaker Profiles (6 tools)
list_speaker_profilesโ List all speaker profilesget_speaker_profileโ Get a profile by namecreate_speaker_profileโ Create a new speaker profileupdate_speaker_profileโ Update a speaker profiledelete_speaker_profileโ Delete a speaker profileduplicate_speaker_profileโ Duplicate a speaker profile
๐ Commands (4 tools)
submit_command_jobโ Submit a command for background processingget_command_job_statusโ Get command job statuslist_command_jobsโ List command jobscancel_command_jobโ Cancel a running command job