This structure highlights the major difference between traditional REST API
rigid structure request and responses which is typically in JSON format.
Notice the response of the handle_call_tool(...) function is a TextContent
object. This response is more compatible with LLMs since they receive text-based
inputs.
Test The Implementation
I tested the MCP server by running it in the terminal:
At this point, I am just looking for syntax errors. Since we need to setup the
MCP Client, either in Cursor, Claude Code, or Claude Desktop, we can test the
MCP server.
(Optional) Adding Custom Commands To Claude Code
I added a custom command to Claude Code to convert images to WebP format. This
way, the same tool is used to convert images.
I had difficulty when I did not explicitly tell Claude Code to
use the 'magick' tool. Claude would attempt to use non-installed commands.
I added the prompt to the .claude/webp.md file for the repo directory.
Markdown
1# Convert To WebP23Look at the directory public/assets/images/ and check for images that are not in
4WebP format.
5You can skip any non-image files, files that are already WebP, or GIFs.
6SKIP GIFs.
78Example:
910magick convert input.png -quality 70 output.webp && rm input.png
1112You can delete the original file after converting to WebP.
13When you have finished, show the amount and percentage of saved space from images
14converted.
15
Make sure the MCP server is running if it requires to be running locally. The
documentation for the MCP server will tell you if it requires to be running
locally.
In this case, I am using Claude Code but any client that supports MCP will work.
In Claude Code, there are a couple ways to add the MCP server. I added directly
to the ~/.claude.json file.
There are many files you could possibly add the MCP server to because Claude
Code allows you to add at a project, user, or global level. In my choice, I
added to the user level.
The mcpServers field may exist at different places in the file. Use
the highest level of the file for user level config.
You may need to use full paths. Note that I reference the `env/bin/python3`
in the command field. I wanted to be explicit to use the executable in the
virtual environment which has the dependencies.
I had to disable my other MCP servers which were returning errors. The errors
on my Brave Search MCP were blocking the Free Stock Images MCP server from
running.
Results
Overall, I am happy with the results. My goal shortening "Old Process" by any
amount of time is mission accomplished.
But there are some shortfalls I have found in the process:
Image selection can be low quality. Some of the images had watermarked text
which I removed the image manually from the blog.
The images were not topical to the blog 30% of the time. For example, an image I
dropped from the final blog was a picture of a steel factory. Perhaps the
blog talked about "building" and a factory was chosen.
Pitfalls
Error when calling the MCP server
Make sure you are running the MCP server locally. In this example, we use Python
to run locally. Some MCP local servers may require npm or some other package to
run.
My specific MCP server will not run. Instead other MCP servers run
Use more explicit prompts to the MCP server. In this example, I had to say the
words "Unsplash free stock images" to get the MCP server to run.