Obsidian logo

Obsidian

Read and search through Markdown notes in Obsidian vaults, with support for backlinks, tags, and metadata.

How to Use Model Context Protocol (MCP) in Cursor

What is MCP?

Model Context Protocol (MCP) is an open protocol that allows you to provide custom tools to agentic LLMs (Large Language Models) in Cursor's Composer feature.

Installation Steps

  1. Open Cursor Settings
    • Navigate to Cursor Settings > Features > MCP
    • Click the "+ Add New MCP Server" button
  2. Configure the Server
    • Name: Give your server a nickname
    • Type: Select the transport type (stdio or sse)
    • Command/URL: Enter either:
      • For SSE servers: The URL of the SSE endpoint
      • For stdio servers: A valid shell command to run the server

Example Configurations

For stdio Server (Obsidian Example):

Command: node ~/mcp-quickstart/obsidian-server/build/index.js --vault-path $OBSIDIAN_VAULT_PATH --api-key $OBSIDIAN_API_KEY

For SSE Server:

URL: http://localhost:27123/sse

Using MCP Tools

Tool Availability

  • • After adding a server, it will appear in your MCP servers list
  • • You may need to click the refresh button to populate the tool list

Using Tools in Composer

  • • The Composer Agent automatically uses MCP tools when relevant
  • • You can explicitly prompt tool usage by:
    • Referring to the tool by name
    • Describing the tool's function

Tool Execution Process

  • • Displays a message in chat requesting approval
  • • Shows tool call arguments (expandable)
  • • Executes the tool upon user approval
  • • Displays the tool's response in the chat

Important Notes

  • • MCP tools may not work with all models
  • • MCP tools are only available to the Agent in Composer
  • • For Obsidian integration, you need to set up OBSIDIAN_VAULT_PATH and OBSIDIAN_API_KEY environment variables
  • • Set your vault path to the absolute path of your Obsidian vault
  • • Install the Obsidian Local REST API plugin and get your API key
  • • For security, use a wrapper script that sets the environment variables before running the server
  • • Ensure proper file permissions for vault access
  • • Consider using read-only access for sensitive vaults
  • • Implement proper error handling for file operations
  • • Be mindful of vault size and search performance
  • • Use appropriate caching for frequently accessed notes
  • • Follow Obsidian's link and embedding conventions
  • • Consider implementing backup strategies
  • • Handle YAML frontmatter parsing carefully