Welcome to the mcp-server-project! 🚀
This project is a demonstration of a local server implementing the Model Context Protocol (MCP). It provides a simple todo server with a couple of tools that can be consumed by an MCP-compatible client, like the Gemini CLI.
This server exposes two tools:
getFirstIncompleteTodo: Fetches a list of todos from JSONPlaceholder and returns the title of the first incomplete one. 📝getFirstCompletedTodo: Fetches a list of todos from JSONPlaceholder and returns the title of the first completed one. ✅
Before you begin, ensure you have the following installed:
- Node.js (which includes
npm) - An MCP-compatible client like Gemini CLI.
-
Navigate to the server directory:
cd mcp-server -
Install dependencies:
npm install
-
Build the server:
npm run build
This will compile the TypeScript source files into JavaScript in the
distdirectory.
To make the gemini-cli aware of this local MCP server, you need to register it.
-
The
mcp-serverdirectory already contains a.mcp.jsonfile that tells the CLI how to start the server: -
Now, you need to tell your Gemini CLI where to find this server. You can do this by editing the
mcp.servers.jsonfile in your Gemini configuration folder.This folder is typically located at:
- Windows:
C:\Users\<YourUser>\.gemini\ - Linux/macOS:
~/.gemini/
Create a file named
mcp.servers.jsonin that directory if it doesn't already exist. - Windows:
-
Add the absolute path to the
mcp-serverdirectory inside theincludearray inmcp.servers.json.Example
mcp.servers.json:{ "include": [ // Make sure to use the correct absolute path for your system! "D:\\_code-projects\\_Gemini-cli-test-folder\\mcp-server-project\\mcp-server" ] }⚠️ Important: You must use an absolute path to themcp-serverfolder. Relative paths may not work correctly.
Once the server is configured, you can start using the tools directly from the Gemini CLI! The CLI will automatically start the server in the background when you try to use one of its tools.
Example 1: Get the first incomplete todo
getFirstIncompleteTodoExample 2: Get the first completed todo
getFirstCompletedTodoAnd that's it! The Gemini CLI will connect to your local MCP server, execute the tool, and return the result. 🎉 Happy coding!