In the previous chapters, we successfully created an MCP Server. Now, we need to tell Cursor how to find and use this server. This is done through a configuration file.
Creating the Configuration File
-
First, open any project in Cursor (it can be a new project or an existing one).
-
Create a
.cursor
folder in the project root (if it doesn’t exist):Terminal window mkdir .cursor -
Create an
mcp.json
file in the.cursor
folder:Terminal window touch .cursor/mcp.json -
Add the following configuration to the
mcp.json
file:{"mcpServers": {"about-me": {"command": "uv","args": ["--directory","/Users/{your_username}/Code/Playground/build_mcp_for_cursor/project","run","main.py"]}}}
Understanding the Configuration
Let’s break down each part of this configuration file:
-
mcpServers
- This is the main section that defines all MCP servers
-
about-me
- This is our server name, which must match the name in
FastMCP("about-me")
- You can change this name, but ensure it matches in both places
- This is our server name, which must match the name in
-
command
- Specifies which command to use to run the server
- We’re using
uv
, our package manager
-
args
- List of command arguments, including:
--directory
: Specifies the project directory- Project path: You need to replace this with your actual project path
run
: The uv run commandmain.py
: The Python file to run
- List of command arguments, including:
Enabling the MCP Service
After creating the configuration file, we need to enable the service in Cursor:
-
Open Cursor Settings
- Windows/Linux: Click the gear icon in the bottom left or use
Ctrl + ,
- macOS: Click the gear icon in the bottom left or use
Cmd + ,
- Windows/Linux: Click the gear icon in the bottom left or use
-
In the Settings panel:
- Find and click “MCP” in the left sidebar
- You should see our “about-me” service
- Click the “Enabled” option to enable the service
Verifying the Service
Now we can test if our service is working:
-
Open Cursor’s Agent mode
- Click the AI icon in the sidebar
- Or use the keyboard shortcut to open the AI panel
-
Try these test questions:
Q: What's my name?A: [AI will call get_user_name() and return "Lucas Lee"]Q: How old am I?A: [AI will call get_user_age() and return 30]
If you receive the correct answers, congratulations! Your MCP Server is configured and working properly!
Common Issues
-
Can’t Find MCP Settings?
- Ensure your Cursor is up to date
- Try restarting Cursor IDE
-
Service Appears Grayed Out?
- Check if the configuration file format is correct
- Ensure the project path is correct and accessible
-
Agent Can’t Get Information?
- Make sure the service is properly enabled
- Check if the Python service is running
- Look at Cursor’s log information
Next Steps
Now that you’ve successfully configured and tested your MCP Server, you can:
- Add more custom tools
- Modify the returned information
- Implement more complex functionality
- Explore other possibilities with MCP servers