Skip to main content

Chapter 3 : MCP Server Advanced

MCP Server Best Practices

Please consider below aspects when designing and implementing MCP Servers

  • Implement Security
  • Mitigating Prompt Bloat and Efficient context handling can Lower Token Consumption
  • Using Models Free Vs Paid
    • Trial out both and choose as per business use cases

Using Data Modeling

  • You can combine data to reduce number of Tools. Use data modeling with multiple table joins, bringing data in one Tool instead of many.
  • Data modeling is implemented in backend APIs and will have respective MCP Server Tool.
  • Is available in MCP Server REST.

MCP Server REST Data Modeling

Implement Data modeling by Following these example steps -

Configure Data Modeling in Builder Studio

  • Join tables 1st and 2nd mcp_data_modeling_tbl_join_1_2.png

  • Join tables 2nd and 3rd

mcp_data_modeling_tbl_join_3rd.png

  • Verify API call output in Swagger

mcp_data_modeling_api_out.png

Use Data Modeling in MCP Server

  • MCP Server project with data modeling

mcp_with_data_modeling.png

Compare Tool calls without and with data modeling

  • MCP Server Tools called when no data modeling
  • Prompt

mcp_data_wo_dm_1.png

  • LLM actions : Multiple Tools called

mcp_data_wo_dm_2.png

  • MCP Server Tools called with data modeling
  • Prompt

mcp_data_with_dm_1.png

  • LLM actions : Only one Tools called

mcp_data_with_dm_2.png

  • LLM actions : Final message

mcp_data_with_dm_3.png

Configure Multiple MCP Servers

AI-Ready Data from multiple databases

  • Please follow Readme in downloaded dir:
    • mcp\spring-java\README-MCP-Server.md
  • Look For Section: How to setup multiple MCP Servers

MCP Server Limitations

Large Responses

caution

When calling the MCP Server Tool, if response is very large, you will get buffer exceeded notice in cursor chats. In such case:

  • Narrow down response by fetching fewer data. e.g. Use Tools for queried data or get by key data, over get table data (ViewAll) which is full table data.

MCP Server Max Tools Limit

  • Cursor allows maximum total of 40 Tools from all MCP Servers. Based on LLM model recommendations.

  • Also Server Name + Tool Name length must be <= 60 chars only.

  • Exceeding Total Tools Limit Notification

mcp_tool_limit_notification.png

Solutions For Maximum Tools Limit

Best solution is to design MCP Server Tools properly.

  • Remove un-used Tools from generated code. See How to Enable/Disable Tools in previous chapter.
  • Use data modeling.
    • Refer to Using Data Modeling
  • For data needed across multiple database connections via Tools, one can use Data Mesh on API side and provide one API endpoint = one Tool.
  • If you still hit MCP Server 40-Tool Limit in Cursor, There are some open source mcp proxy solutions available, as mentioned in Cursor forums. Search in forums for such solutions.