Use this page to help an AI client remember and use MoContext. Copy the short bootstrap into persistent custom instructions, or copy the longer session prompt into a single chat when you want to steer that session.
Paste this into an AI client's custom instructions so new sessions know to check for MoContext.
Paste this into a chat when you want the current session to actively use MoContext.
Appendix: how MoContext works
Audience: Technical users and admins. Covers architecture, data flows, HTTP endpoints, and MCP tools. For internal codebase detail (service layer, file map, WinForms threading, startup sequence) see MoContext_Codebase.html.
MoContext is a single-executable, local-loopback server that gives AI agents (and developers) two things: grounded source retrieval from the MoSearch full-text index, and a lightweight activity journal for recording what the AI worked on. It exposes the same surface over two parallel entry points — a classic REST HTTP API and a Model Context Protocol (MCP) endpoint — and ships a WinForms system-tray dashboard for monitoring.
MoContextRepository owns all MoContext.db access. EvidencePackService opens MoSl.db directly (read-only). No other service touches a database.MoSl.db is the read-only FTS database that MoSearch builds and owns. MoContext.db lives beside it in the same AppData folder as MoContext's own write-side store.
MoContext sits between AI clients and the local filesystem. MoSearch's indexer is a fully separate process that writes MoSl.db; MoContext only reads it. The MoSearch Search UI is the original user-facing query tool — it reads the same MoSl.db and opens source files directly; HTTP and MCP are two new avenues into that same underlying index.
This is the most important structural point. MCP is not layered on top of HTTP. Both entry points call the same service singletons through ASP.NET Core DI. The MCP SDK registers a handler at /mcp alongside the /v1/ route handlers — they are peers, not stacked.
MoContext works with two SQLite databases. They typically live in the same %LOCALAPPDATA%\Meauxsoft\Mo-Search<ver>\ AppData folder but are structurally independent. MoSearch owns and writes MoSl.db; MoContext only reads it. MoContext owns and reads/writes MoContext.db.
GET/POST /v1/...| Method + Path | Description / Parameters | Example |
|---|---|---|
| GET /v1/health | Returns compact liveness/readiness: server version, status, database readiness, indexed-extension count, and warnings. Safe to poll at any time. Use diagnostics when you need runtime paths or deployment provenance. | |
| GET /v1/capabilities | Returns all configured budgets: max_files, max_windows_per_file, context_lines, max_total_lines, max_total_chars, and supported search modes. Call once at session start to understand server limits before querying. | |
| GET /v1/activity/recent | Activity log entries newest-first. Params: days, session_id, topic_key, q (substring search within summary_text), limit. All params optional and combinable. |
|
| GET /v1/activity/briefing | Plain-text summary of recent activity formatted for AI context injection. Params: days, max_chars, topic_key. |
|
| GET /v1/activity/topics | Lists active topic_key slugs with entry counts — useful for discovering ongoing work threads. Params: days, q, limit. |
|
| GET /v1/context/search | Ranked file search without reading source text — faster than evidence-pack when you only need to discover which files contain a query. mode: keyword (any word) or phrase (exact order). Returns files[]{path, rank, loader_family}. Params: query, mode, max_files, path_filter, filename. |
|
| GET /v1/context/browse | Lists recently indexed files ordered by recency — no query required, good for project discovery. Returns files[]{path, indexed_at, loader_family, word_count}. Params: limit, path_filter (e.g. src\Services), filename (e.g. .cs). |
|
| GET /v1/context/evidence-pack | Retrieves bounded source-code windows for a query. Returns files[]{path, windows[]{lines[]{line_number, text}, hit_line}}. Params: query, mode (keyword/phrase/all), max_files, max_windows_per_file, context_lines, path_filter, filename. |
|
| POST /v1/context/file-window | Reads a focused line window from a file by path and center line. Body: { path, line, before?, after? }. Returns the surrounding lines with line numbers. |
|
| POST /v1/context/full-file | Reads a full file or a specific line range. Body: { path, start_line?, end_line? }. Gated by AllowedRoots config. Truncates at max_total_lines. |
|
| GET /v1/events | Raw event log (api_call, mcp_transport, mcp_tool_call, service_lifecycle entries). Params: days, event_type, event_key, limit. |
|
| GET /v1/events/summary | Aggregated event counts grouped by event_key. Useful for usage analytics and auditing which endpoints or tools are called most. | |
| GET /v1/saved-pack | Lists saved pack metadata (title, topic_key, query_text, created_at) newest first. Params: topic_key (optional filter), limit. |
|
| GET /v1/saved-pack/{id} | Retrieves one saved pack entry by numeric ID. |
| Method + Path | Description / Parameters | Example |
|---|---|---|
| POST /v1/session/start | Creates a new session and returns its session_id. Body: { client_name? }. Use the returned ID with subsequent /v1/activity calls to group work under one session. |
|
| POST /v1/activity | Records a work-checkpoint note. Body: { session_id, summary_text, topic_key?, next_step_text?, query_hint? }. summary_text is 1–3 sentences of completed work (not what comes next). |
|
| POST /v1/saved-pack | Saves pack metadata. Source excerpts are never stored — always re-retrieved fresh from the index. Body: { title (required), topic_key?, summary_text?, query_text? }. |
|
| POST /v1/context/evidence-pack | Write variant of the evidence-pack endpoint. Accepts a JSON body with all evidence-pack params, plus an optional activity_note field to record a checkpoint in the same call. |
|
| POST /v1/admin/shutdown | Gracefully stops the MoContext server process. Protected by Bearer token if AuthToken is configured. | |
| POST /v1/admin/show-window | Brings the WinForms dashboard to foreground. Also used by the single-instance check at startup to surface an already-running instance. |
Every /v1/ request records an api_call event (fire-and-forget). Every /mcp request records an mcp_transport event. Individual MCP tools also record mcp_tool_call events.
MoContextMcpTools.cs)MoContext currently exposes 22 MCP tools. Important first-call and context-file tools include get_server_summary, get_usage_guide, get_diagnostics, get_context_paths, list_context_files, read_context_file, and write_memory_file. The table below summarizes the core retrieval and activity tools with examples; MCP clients should trust tools/list for the exact current schema.
| Tool name | Description / Parameters | Example |
|---|---|---|
| get_health | Return compact MoContext liveness, version, database readiness, indexed-extension count, and warnings. No parameters required. Use get_diagnostics for runtime paths, deployment provenance, database paths, and the full indexed-extension inventory. |
|
| get_capabilities | Return effective retrieval budgets (max_files, context_lines, max_total_lines, etc.) and supported search modes. No parameters. Call once at session start to understand server limits before making retrieval calls. | |
| browse_context | List recently indexed files without a query — useful for project discovery at the start of a session. Files ordered by index recency. Params: limit, path_filter (e.g. src\Services), filename (e.g. .cs, Program). Returns: files[]{path, indexed_at, loader_family, word_count}. Use get_evidence_pack when you need actual source excerpts. |
|
| search_context | Search the FTS index and return ranked file matches without reading source text — faster than get_evidence_pack when you only need to discover which files contain a query. mode: keyword matches any listed word independently; phrase requires the exact phrase in order. Params: query, mode, max_files, path_filter, filename. Returns: files[]{path, rank, loader_family}. |
|
| get_evidence_pack | Retrieve bounded source-code windows for a query. mode: keyword, phrase, or all (recent files, no query filter). context_lines overrides the server default lines before/after each hit. Returns: files[]{path, windows[]{lines[]{line_number, text}, hit_line}}. Example: {query:'session token validation', mode:'phrase', path_filter:'Services', max_files:5}. |
|
| get_file_window | Read a focused line window from a local file by path and center line. Params: path, line, before?, after?. Returns the surrounding lines with line numbers. |
|
| get_full_file | Read a full local file or a specific line range over HTTP-safe MCP transport. Params: path, start_line?, end_line?. Gated by AllowedRoots config. Truncates at max_total_lines. |
|
| get_recent_activity | Return activity log entries newest-first. All params optional and combinable: days, session_id, topic_key (exact-match slug), q (substring search within summary_text), limit (default 50, max 200). Examples: {days:7, limit:20} for a week recap; {topic_key:'auth-refactor'} for topic history; {q:'JWT', days:30} to search by keyword. |
|
| get_activity_briefing | Build a plain-text briefing from recent activity for AI context injection. Params: days, max_chars (200–8000, default 2000), topic_key. |
|
| get_activity_topics | List active topic keys from recent activity with entry counts. Params: days, q (optional search filter), limit. |
| Tool name | Description / Parameters | Example |
|---|---|---|
| start_session | Create a new activity session and return its session_id. Param: client_name?. Use at the start of each conversation to group subsequent activity notes under one session. |
|
| record_activity | Save a work-checkpoint note. session_id comes from start_session. summary_text is 1–3 sentences of completed work (not what's next). topic_key groups related work across sessions. next_step_text and query_hint are optional. Only call at meaningful milestones, not after every tool invocation. Example: {session_id:'sess-3f9a1c02', summary_text:'Refactored JWT validation into AuthService.', topic_key:'auth-refactor', next_step_text:'Wire AuthService into the login endpoint.'}. |
|
| save_pack | Save lightweight metadata about a meaningful evidence pack. Source excerpts are never stored — always re-retrieved fresh from the index. Params: title (required), topic_key?, summary_text?, query_text?. |
|
| list_saved_packs | List saved pack metadata entries, newest first. Params: topic_key (optional filter), limit (default 50, max 200). |
|
| get_saved_pack | Retrieve one saved pack metadata entry by its numeric ID. Returns title, topic_key, summary_text, query_text, and created_at. |
MCP uses ModelContextProtocol.AspNetCore 1.1.0. Transport: Streamable HTTP with stateful sessions (Mcp-Session-Id header). Protocol version: 2025-11-25. Tools are discovered via WithToolsFromAssembly() — all [McpServerTool] methods in the assembly are registered automatically.
Section 11 (Startup Sequence) — moved to MoContext_Codebase.html.
Generated from MoContext source — MoContext\src\MoContext.Server\docs\MoContext_Overview.html