Practical Guide to Building Effective Agent Tools

Key Points of This Article
- Practical practices for creating/improving MCP tools
- Concrete improvement examples through OSS contributions
I'm Higashi, an Engineering Manager at JAPAN AI.
JAPAN AI is an AI Agent Platform service for Japanese business users. We provide not only AI Agents that handle various tasks, but also functionality that allows customers to build AI Agents themselves.
JAPAN AI AGENTjapan-ai.co.jpIntroduction
Until now, JAPAN AI has been developing tools that integrate with agents in-house, with particular focus on integration with tools essential for Japanese business users' work, such as Calendar and Mail services.
Integration is not simply a matter of wrapping REST endpoints to enable CRUD operations. It requires careful design of what inputs to accept and what outputs to produce so that LLMs can collaborate effectively and accurately complete tasks, considering the series of scenarios users intend to perform on the chat interface. This is a deep and complex challenge.
We have spent considerable time improving these interfaces and adding functionality. However, developing everything in-house is resource-intensive and increases maintenance costs. Additionally, as services increasingly implement their own MCP servers or publish their code, the necessity of in-house implementation has decreased.
Given this situation, JAPAN AI has shifted to a strategy of quickly integrating MCP servers by preparing infrastructure, connecting to officially published MCP servers, and hosting OSS MCP servers for utilization. We are focusing on activities that can enhance service value by leveraging OSS power while contributing back to those communities.
Today, I'll discuss Klavis, an MCP server OSS we've been paying attention to recently, and our contribution activities.
What is Klavis?
https://github.com/Klavis-AI/klavis
Features
| Feature | Description |
|---|---|
| 100+ Pre-built Integrations | Supports major services like Google Sheets, Slack, GitHub, Gmail |
| Excellent MCP Design | Unified interface design that's easy to extend and customize |
| Multiple Deployment Options | Choose from Cloud / Self-hosted / SDK / REST API |
| Apache-2.0 License | Open source with peace of mind for commercial use |
Why We Chose Klavis
- Excellent MCP Design Interface
- Each MCP server is well-designed, easy to understand, and extensible
- Active Development Community
- Approximately 5,500 Stars, 500+ Forks, active release cycle
- Future Potential
- Design philosophy that allows handling multiple tools with one MCP server through Strata integration layer
We decided to adopt it based on the abundance of tools and consistent functional design. As it's still a developing project, we found areas for improvement. Today, I'll introduce our work on improving Google Sheet MCP Tools and adding Excel MCP servers that we noticed during usage.
Principles and Practices of Effective MCP Tool Design
Before sharing the actual work we undertook, let me introduce some guidelines for creating effective tools from Anthropic's "Building Effective AI Agents" and "Writing effective tools for AI agents—using AI agents."
Practice 1: Tool Consolidation
More tools don't always lead to better outcomes.
Related functions should be consolidated into one tool. As the number of tools increases, agents have more choices, leading to confusion and context consumption. For example:
list_users、list_events、create_event→ consolidate intoschedule_eventread_logs→search_logs(return only relevant lines)
Practice 2: Returning Meaningful Context
Prioritize semantic clarity over technical completeness.
Return only the information needed for agents to determine the next action. Instead of returning all acquired raw data, make it possible to select the necessary format at runtime according to use cases. For example:
Add a response_format parameter and make it possible to choose "concise"/"detailed" according to subsequent processing needs, returning only the values needed for each use case.
Practice 3: Setting Appropriate Default Values
We restrict tool responses to 25,000 tokens by default.
Implement pagination, range selection, and filtering, with default values optimized for the most common use cases. This prevents agents from unintentionally acquiring large amounts of data and consuming context.
Practice Example 1: Google Sheets Tool Improvement
Based on these principles, we improved the Google Sheets Tool.
Challenge
The first problem we faced when using Klavis's Google Sheets Tool was that it would retrieve entire sheet data, reaching LLM context limits.
Large spreadsheets often contain tens of thousands of cells of data. Passing all of this to the LLM exceeds token limits and causes errors. The inability to specify ranges during retrieval is a critical problem, and retrying would fetch the same data, leaving agents with no way to avoid this.
Furthermore, response verbosity was also problematic. The Google Sheets API can retrieve both userEnteredValue (raw input values/formulas) and formattedValue (calculated results/display values), but by default, both were returned. For most use cases, only the calculated results (formattedValue) are sufficient.
Improvement Approach
We improved this problem gradually with two PRs:
| PR | Content |
|---|---|
| #653 | • Added new tool google_sheets_get_range for range specification |
| #681 | • Consolidated into google_sheets_get_range, google_sheets_get_spreadsheet • Added response format options |
In the first PR, we initially added range specification functionality as a new tool. This allowed retrieving only necessary ranges and avoiding context limits. However, there were still problems:
- Two tools with overlapping roles:
google_sheets_get_rangeandgoogle_sheets_get_spreadsheet - Response content remained verbose
So we made further improvements in the second PR. The Before/After is as follows.
Input Before/After
Before: Interface that only specifies spreadsheet_id and can only retrieve all data
google_sheets_get_spreadsheet
└── spreadsheet_id (required)→ Returns all sheet data with userEnteredValue + formattedValue
After: Interface that can specify range and format
google_sheets_get_spreadsheet
├── spreadsheet_id (required)
├── range (optional): Range specification in A1 notation (e.g., 'Sheet1!A1:D100')
└── cell_value_format (optional): 'formatted' | 'userEntered' | 'all'| Parameter | Description |
|---|---|
| range | Specify retrieval range in A1 notation. When omitted, retrieves all sheet data |
| cell_value_format | formatted (default): Display values only, userEntered: Input values including formulas, all: Both |
Output Before/After
The default response format was also optimized, and responses now change based on the cell_value_format parameter value as follows. Here's the response content for a sheet like this:

Before: Returns both userEnteredValue and formattedValue
{"1":{
"A":{"userEnteredValue":"日付","formattedValue":"日付"},
"B":{"userEnteredValue":"売り上げ","formattedValue":"売り上げ"}
},
"2":{
"A":{"userEnteredValue":45658,"formattedValue":"2025/01/01"},
"B":{"userEnteredValue":100,"formattedValue":"100"}
},
"3":{"A":{"userEnteredValue":"=A2+1","formattedValue":"2025/01/02"},
"B":{"userEnteredValue":200,"formattedValue":"200"}},
"4":{"A":{"userEnteredValue":"合計","formattedValue":"合計"},
"B":{"userEnteredValue":"=SUM(B2:B3)","formattedValue":"300"}}}→ When userEnteredValue == formattedValue, results in verbose responses.
After: cell_value_format selection (default=formatted)
// formatted
{"1":{"A":"日付","B":"売り上げ"},"2":{"A":"2025/01/01","B":"100"},"3":{"A":"2025/01/02","B":"200"},"4":{"A":"合計","B":"300"}}
// userEntered
{"1":{"A":"日付","B":"売り上げ"},"2":{"A":45658,"B":100},"3":{"A":"=A2+1","B":200},"4":{"A":"合計","B":"=SUM(B2:B3)"}}
// all
// → Same format as Before
For most use cases, knowing "what is displayed in the cell" is sufficient. We designed it so that userEntered is specified only when you want to check formula contents.
Improvement Effects
| Aspect | Improvement |
|---|---|
| Token Efficiency | Can retrieve only necessary ranges/formats, saving tokens even with large spreadsheets |
| Tool Design | Consolidated as extension of existing tools, reducing agent selection errors |
| Usability | Default optimized for most common use case (display values only) |
| Backward Compatibility | Maintains same behavior as before when parameters are omitted (→ all) |
Practice Example 2: Adding New Excel MCP Server
Since many JAPAN AI customers use Microsoft Office, we implemented an Excel MCP server with the same design as Google Sheets to provide consistent service (PR #713).
Provided Tools
We implemented the following tools similar to Google Sheets:
| Tool Name | Description |
|---|---|
| microsoft_excel_create_workbook | Create new workbook in OneDrive/SharePoint |
| microsoft_excel_get_worksheet | Get worksheet data (supports range and format specification) |
| microsoft_excel_write_to_cell | Write values to specified cells |
| microsoft_excel_list_worksheets | Get list of worksheets in workbook |
microsoft_excel_get_worksheet implements the range and cell_value_format parameters added in the Google Sheets improvement from the beginning.
Design Differences from Google Sheets
Even for the same "spreadsheet operations," we adjusted interfaces according to service characteristics:
| Item | Google Sheets | Excel |
|---|---|---|
| File Identification | spreadsheet_id (ID only) | workbook_url (full URL) |
| File List Retrieval | Has list_spreadsheets | None (explained below) |
① Why doesn't Excel provide list_workbooks?
Unlike Google Drive, OneDrive/SharePoint search APIs have low reliability and may not return expected results. Also, basic Excel data usage agent use cases primarily involve direct access from shared links or browser URLs.
"Practice 1: Tool Consolidation" also includes the concept of "don't add unnecessary tools." Rather than providing unstable list retrieval functionality, we designed to focus on reliable URL-based access.
② Why use workbook_url instead of spreadsheet_id?
Excel file URLs exist in multiple formats (Doc.aspx URL, excel.cloud.microsoft URL, standard shared links, etc.). Since workbook_id extraction methods differ slightly for each URL format, it's more reliable to receive URLs directly and parse them server-side rather than having LLMs extract IDs.
This aligns with the "poka-yoke" concept introduced in Anthropic's article:
"Apply poka-yoke principles—restructure tool arguments to make misuse harder."
Summary
This time, we contributed to Klavis by practically applying tool design principles advocated by Anthropic along with our experience building tools at JAPAN AI.
At JAPAN AI, we position OSS contribution as "investment for product quality improvement." We believe we can contribute to the development of the entire ecosystem by honing the technology needed to solve customer issues and sharing the knowledge gained in that process with the community.
Going forward, we want to actively promote a culture where team members contribute to OSS, creating a cycle of improving our technical capabilities as an organization by incorporating external knowledge while enhancing our strength as a technical organization.
Recruitment Message
JAPAN AI is advancing the construction of AI agent infrastructure utilizing MCP. If you're interested in this field and want to build products together, let's talk!
【JAPAN AI】Product AI Engineer | Geniee Inc.
Job information for 【JAPAN AI】Product AI Engineer (Geniee Inc.) | HRMOS
[Image]
https://hrmos.co/pages/geniee/jobs/1798934024832237907
Want to talk about EM work in generative AI SaaS business
"Want to talk about EM work in generative AI SaaS business" - Tetsushi Higashi
[Image]
https://pitta.me/matches/SxUgiatPgTAH