Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/mcp/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ export class OmemClient {
limit = 10,
scope?: string,
tags?: string[],
space?: string,
): Promise<SearchResult[]> {
const safeQ = query.length > 500 ? query.slice(0, 500) : query;
const params = new URLSearchParams({ q: safeQ, limit: String(limit) });
if (scope) params.set("scope", scope);
if (tags && tags.length > 0) params.set("tags", tags.join(","));
if (space) params.set("space", space);
const res = await this.request<SearchResponse>(
`/v1/memories/search?${params}`,
);
Expand Down
11 changes: 9 additions & 2 deletions plugins/mcp/src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function registerTools(server: McpServer, client: OmemClient): void {
{
title: "Search Memories",
description:
"Search stored memories by semantic query. Returns the most relevant memories ranked by similarity.",
"Search stored memories by semantic query. Returns the most relevant memories ranked by similarity. By default searches across all spaces the caller has access to (personal + team + organization). Pass `space` to restrict to specific spaces — useful when you want a query scoped to one context (e.g. work-only) or to peek into a non-default space (e.g. 'this question is about something in our team space').",
inputSchema: {
query: z.string().describe("Search query"),
limit: z
Expand All @@ -73,15 +73,22 @@ export function registerTools(server: McpServer, client: OmemClient): void {
.array(z.string())
.optional()
.describe("Filter by tags"),
space: z
.string()
.optional()
.describe(
"Restrict search to specific spaces. Comma-separated space IDs (e.g. 'personal:doc,team:synchresis-work'), a single ID, or 'all' for every accessible space. Omitted = all accessible spaces.",
),
},
},
async ({ query, limit, scope, tags }) => {
async ({ query, limit, scope, tags, space }) => {
try {
const results = await client.searchMemories(
query,
limit ?? 10,
scope,
tags,
space,
);

if (results.length === 0) {
Expand Down
Loading