使用说明
LocalNotes Search MCP Server
A great "Hello World" for an MCP implementation for STDIO is a Local Notes Searcher.
It’s simple enough to understand but demonstrates the core power of MCP: giving an LLM access to private, local data that it otherwise couldn't see. In this example, the LLM will be able to read .txt files from a specific folder on your computer to answer your questions.
Features
- Transport: Uses STDIO (Standard Input/Output) for communication.
- Tools:
read_note: Takes afilenameand returns the text content of the file from the locally configurednotesdirectory.
Prerequisites
- Java 21 or later
- Maven 3.6 or later
Build Instructions
To build the application, run the following command in the project root:
mvn clean package
This will create an executable JAR file in the target/ directory (e.g., target/mcp-server-localnotes-search-stdio-0.0.1-SNAPSHOT.jar).
Configuration
The application uses a notes directory to store and read text files. By default, it looks for a directory named notes in the current working directory.
You can configure the location of this directory using the notes.directory property in application.properties or via command-line arguments:
# Run with a custom notes directory
java -jar target/mcp-server-localnotes-search-stdio-0.0.1-SNAPSHOT.jar --notes.directory="/absolute/path/to/notes"
Setup
- Create a directory named
notesin the same directory where you will run the JAR. - Add some
.txtfiles to thisnotesdirectory (e.g.,hello.txt).
Run Instructions
You can run the application directly with Java. Since it uses STDIO, it expects JSON-RPC messages via standard input.
java -jar target/mcp-server-localnotes-search-stdio-0.0.1-SNAPSHOT.jar
Usage with an MCP Client
Configure your MCP client (like Claude Desktop or an IDE extension) to run the above command.
Manual Testing
You can interact with the server manually by pasting JSON-RPC messages into the console after running the JAR.
Initialize:
{"jsonrpc": "2.0", "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test-client", "version": "1.0"}}, "id": 1}
Call Tool (read_note):
{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "read_note", "arguments": {"filename": "hello.txt"}}, "id": 2}
