Skip to content

Your First Tool

Start with a simple pricing calculator:

# Permissions:
# No external access needed
#
# Callers:
# Any MCP client
Ask "Customer tier?" as customer tier
Ask "Deal size?" as deal size
discount_rate equals 0.05
If customer_tier is "premium"
discount_rate equals 0.10
If customer_tier is "enterprise"
discount_rate equals 0.15
If deal_size is less than 10000
Fail with record with "minimum_not_met" as code and "Deal size must be at least $10,000" as message
discount equals deal_size times discount_rate
Respond with record with discount as amount and discount_rate as rate and customer_tier as tier

Save this as tools/calculate_discount.dvl.

Create devlish.toml in the same directory:

name = "pricing-tools"
version = "0.1.0"
[[tools]]
source = "calculate_discount.dvl"
description = "Calculate the discount amount for a deal based on customer tier and size"
[tools.inputs]
customer_tier = { type = "string", description = "Customer tier: standard, premium, or enterprise" }
deal_size = { type = "number", description = "Total deal value in dollars" }
Terminal window
devlish mcp --tools-dir ./tools/

The server registers your tool with any connected MCP client (Claude Desktop, Cursor, custom agents).

Add to your claude_desktop_config.json:

{
"mcpServers": {
"pricing": {
"command": "devlish",
"args": ["mcp", "--tools-dir", "/path/to/tools"]
}
}
}

Restart Claude Desktop. The tool appears in the tool list.

When Claude decides to call your tool, it sends:

{"customer_tier": "enterprise", "deal_size": 500000}

Your program runs and returns:

{
"success": true,
"responded": true,
"response": {"amount": 75000, "rate": 0.15, "tier": "enterprise"}
}

If the input is invalid (deal_size too small), it returns:

{
"success": false,
"response": {"code": "minimum_not_met", "message": "Deal size must be at least $10,000"}
}

The LLM reads the code field, understands the error, and retries with corrected input.