Skip to main content
Glama
camiloluvino

Roam Research MCP Server

by camiloluvino

roam_remember

Store memories and information in Roam Research by adding them to the daily page with tagging and categorization for organized knowledge retention.

Instructions

Add a memory or piece of information to remember, stored on the daily page with MEMORIES_TAG tag and optional categories. NOTE on Roam-flavored markdown: For direct linking: use [[link]] syntax. For aliased linking, use alias syntax. Do not concatenate words in links/hashtags - correct: #[[multiple words]] #self-esteem (for typically hyphenated words). IMPORTANT: Before using this tool, ensure that you have loaded into context the 'Roam Markdown Cheatsheet' resource.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memoryYesThe memory detail or information to remember
categoriesNoOptional categories to tag the memory with (will be converted to Roam tags)

Implementation Reference

  • Core handler implementation for the 'roam_remember' tool. Adds a memory block tagged with MEMORIES_TAG to today's daily page, creating the page if necessary, and optionally adds category tags.
    async remember(memory: string, categories?: string[]): Promise<{ success: boolean }> { // Get today's date const today = new Date(); const dateStr = formatRoamDate(today); // Try to find today's page const findQuery = `[:find ?uid :in $ ?title :where [?e :node/title ?title] [?e :block/uid ?uid]]`; const findResults = await q(this.graph, findQuery, [dateStr]) as [string][]; let pageUid: string; if (findResults && findResults.length > 0) { pageUid = findResults[0][0]; } else { // Create today's page if it doesn't exist try { await createPage(this.graph, { action: 'create-page', page: { title: dateStr } }); // Get the new page's UID const results = await q(this.graph, findQuery, [dateStr]) as [string][]; if (!results || results.length === 0) { throw new McpError( ErrorCode.InternalError, 'Could not find created today\'s page' ); } pageUid = results[0][0]; } catch (error) { throw new McpError( ErrorCode.InternalError, 'Failed to create today\'s page' ); } } // Get memories tag from environment const memoriesTag = process.env.MEMORIES_TAG; if (!memoriesTag) { throw new McpError( ErrorCode.InternalError, 'MEMORIES_TAG environment variable not set' ); } // Format categories as Roam tags if provided const categoryTags = categories?.map(cat => { // Handle multi-word categories return cat.includes(' ') ? `#[[${cat}]]` : `#${cat}`; }).join(' ') || ''; // Create block with memory, memories tag, and optional categories const blockContent = `${memoriesTag} ${memory} ${categoryTags}`.trim(); const actions = [{ action: 'create-block', location: { 'parent-uid': pageUid, order: 'last' }, block: { string: blockContent } }]; try { const result = await batchActions(this.graph, { action: 'batch-actions', actions }); if (!result) { throw new McpError( ErrorCode.InternalError, 'Failed to create memory block via batch action' ); } } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to create memory block: ${error instanceof Error ? error.message : String(error)}` ); } return { success: true }; }
  • Input schema definition for the 'roam_remember' tool, including parameters for memory text and optional categories.
    [toolName(BASE_TOOL_NAMES.REMEMBER)]: { name: toolName(BASE_TOOL_NAMES.REMEMBER), description: 'Add a memory or piece of information to remember, stored on the daily page with MEMORIES_TAG tag and optional categories. \nNOTE on Roam-flavored markdown: For direct linking: use [[link]] syntax. For aliased linking, use [alias]([[link]]) syntax. Do not concatenate words in links/hashtags - correct: #[[multiple words]] #self-esteem (for typically hyphenated words).\nIMPORTANT: Before using this tool, ensure that you have loaded into context the \'Roam Markdown Cheatsheet\' resource.', inputSchema: { type: 'object', properties: { memory: { type: 'string', description: 'The memory detail or information to remember' }, categories: { type: 'array', items: { type: 'string' }, description: 'Optional categories to tag the memory with (will be converted to Roam tags)' } }, required: ['memory'] } },
  • Tool registration and dispatching logic in the MCP server. Maps 'roam_remember' calls to the toolHandlers.remember method.
    case BASE_TOOL_NAMES.REMEMBER: { const { memory, categories } = request.params.arguments as { memory: string; categories?: string[]; }; const result = await this.toolHandlers.remember(memory, categories); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • Wrapper method in ToolHandlers class that delegates to MemoryOperations.remember.
    async remember(memory: string, categories?: string[]) { return this.memoryOps.remember(memory, categories);
  • BASE_TOOL_NAMES constant defining the base name 'roam_remember' used for handler mapping and schema key generation.
    REMEMBER: 'roam_remember',

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/camiloluvino/roamMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server