Building Ramp's MCP server

We discuss the MCP server we built to let LLMs interact with our resources.

Junho Choi
7 min readintermediate
--
View Original

Overview

The article discusses the development of Ramp's MCP server, which utilizes the Model Context Protocol (MCP) to enable natural language interaction with business data via a SQL interface. It highlights the integration of Ramp's developer API with LLMs, showcasing how this combination enhances data analysis and visualization capabilities.

What You'll Learn

1

How to build an MCP server using FastMCP in Python

2

Why SQL is preferred for data querying in LLM applications

3

How to implement an in-memory ETL process for transforming API data into SQL format

Prerequisites & Requirements

  • Understanding of Model Context Protocol and its applications
  • Familiarity with Python and FastMCP library

Key Questions Answered

What is the Model Context Protocol and how is it used in Ramp's MCP server?
The Model Context Protocol (MCP) is an open-source standard that allows applications to expose data and functionality to LLMs. In Ramp's MCP server, it integrates with the developer API to enable natural language queries on business data, effectively transforming the API into a SQL interface.
How did Ramp address scaling issues with their MCP server?
Ramp faced scaling issues such as miscalculations and high input token usage. They resolved these by implementing a SQL interface that allowed Claude, their LLM, to perform data analysis more efficiently, reducing the amount of raw data loaded into its context window.
What tools were defined to expose functionality to the LLM in Ramp MCP?
Ramp MCP defined several tools including 'load_transactions' for pulling data from the Ramp API, 'process_data' for transforming API data into SQLite tables, and 'execute_query' for running queries on the in-memory database, enhancing the LLM's ability to analyze spend data.
What are the security considerations when using MCP with LLMs?
Using MCP with LLMs introduces information security risks, such as the need to secure authentication credentials like API keys. Ramp mitigates these risks by implementing audit logging and allowing users to constrain OAuth scopes and tools available to the MCP client.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Protocol
Model Context Protocol
Enables applications to expose data and functionality to LLMs.
Library
Fastmcp
Used to build the MCP server in Python.
Database
Sqlite
Utilized for in-memory data storage and querying.

Key Actionable Insights

1
Integrating SQL with LLMs can significantly enhance data analysis capabilities.
By leveraging SQL's structured format, LLMs can handle larger datasets more efficiently, reducing token usage and improving performance.
2
Implementing a lightweight ETL process can streamline data transformation from APIs to SQL databases.
This approach allows for easier querying and analysis, making it essential for applications that rely on dynamic data from various sources.
3
Utilizing audit logging is crucial for maintaining security when exposing sensitive data to LLMs.
This practice helps track data access and ensures that only authorized tools and scopes are available, reducing the risk of data breaches.

Common Pitfalls

1
Relying too heavily on LLMs for data analysis without proper structure can lead to inaccuracies.
LLMs may misinterpret data or provide incorrect outputs if the data format is not predictable, highlighting the importance of structured querying.
2
Neglecting security measures when implementing MCP can expose sensitive data.
Without proper audit logging and constrained access, there is a risk of unauthorized data access, which can lead to significant security breaches.

Related Concepts

Model Context Protocol
Llms And Data Querying
Etl Processes
Data Security In AI Applications