DEV Community

ferdau
ferdau

Posted on

8 thinks I learned implementing my first MCP server.

Thanks for clicking. I try documenting my experiences, writing stuff down motivates me to dive deeper into things. Feel free to provide feedback.

If you are reading this, I'll assume you already know what an MCP server is. I'll save you some time and dive right in.

Low hanging fruit

1. Rethink your access patterns
An LLM interacts with your data in a differently than a regular (web) app. Take time to carefully think through your use cases.

2. Write out the prompts you want to achieve
Write down a few realistic scenarios that reflect how your end users might interact with the LLM. This will help you define the tools better.

Subjective findings

3. Not everything needs to be a tool
This one might be subjective, but I feel that introducing too many tools made the outcomes less predictable. Combining tools might make sense if they align with your access patterns (see #1).

4. Not everything needs to be a tool - part 2
For generic information, avoid creating a tool. If the LLM requires specific context each time, integrate that information directly within the prompt, this reduces tool calls and improves performance.

Practical

5. Implement smart search tools for your entities
Users won't be able to refer to an object with perfect accuracy, especially with voice input. Voice input isn't always great at recognizing names of streets, businesses, etc. That's why a solid search function is essential. Carefully consider which fields should be searchable, these may differ from the usual ones in (web) apps.

6. When using an AI IDE: Keep your MCP code out of the context of your model.
Some models tend to be too eager to solve the task at hand. With your MCP code in context, it might draw conclusions and will try to work around issues with your MCP.

Example 1: If the MCP integration fails on creating a new record, Cursor doesn't mind solving the issue by executing database queries. Yikes.

Example 2: If the MCP integration has missing information, Cursor tends to pull that data from your code base. This often doesn't fix the root cause.

Addendum

7. Keep in mind this is new technology
LLMs are not (yet) great at generating MCP servers. Even with specifications, models like Claude Sonnet often produce incomplete implementations (e.g., missing endpoints).

8. Test your tool across different MCP clients
There are small differences between MCP clients that can affect how your tool behaves. For now it's important to test across multiple clients to catch inconsistencies early.

Top comments (0)