tutorials on cli vibe-coding tools
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: Simple Beauty Data
|
||||
description: Process meta_All_Beauty.jsonl with DuckDB and explain the product and store reports. Use for tasks about the Beauty dataset or its reproducible DuckDB pipeline.
|
||||
---
|
||||
|
||||
# Simple Beauty data workflow
|
||||
|
||||
1. Work from the project directory containing `meta_All_Beauty.jsonl` and `simple-run.sh`.
|
||||
2. Do not print or read the whole JSONL file.
|
||||
3. Run `./simple-run.sh`.
|
||||
4. Read `simple-output/report.txt` and `simple-output/top-stores.csv`.
|
||||
5. Summarize the product count, price availability, and top stores. Distinguish missing prices from zero prices.
|
||||
6. If the user requests a different report, edit `simple-report.sql`, rerun `./simple-run.sh`, and show the new result.
|
||||
7. Treat `simple-run.sh` and the SQL files as the reusable result; do not rely on a previous chat for the numbers.
|
||||
@@ -0,0 +1,28 @@
|
||||
.mode box
|
||||
|
||||
SELECT 'Data quality' AS report;
|
||||
SELECT * FROM data_quality;
|
||||
SELECT * FROM duplicate_parent_asins ORDER BY parent_asin LIMIT 10;
|
||||
|
||||
SELECT 'Ten largest stores by product count' AS report;
|
||||
SELECT *
|
||||
FROM store_summary
|
||||
ORDER BY product_count DESC, store
|
||||
LIMIT 10;
|
||||
|
||||
SELECT 'Ten highly rated products with at least 100 ratings' AS report;
|
||||
SELECT parent_asin, title, store, average_rating, rating_number, price
|
||||
FROM products
|
||||
WHERE rating_number >= 100
|
||||
ORDER BY average_rating DESC, rating_number DESC, parent_asin
|
||||
LIMIT 10;
|
||||
|
||||
SELECT 'Price availability and median price by main category' AS report;
|
||||
SELECT
|
||||
main_category,
|
||||
count(*) AS products,
|
||||
count(price) AS products_with_price,
|
||||
round(median(price), 2) AS median_price
|
||||
FROM products
|
||||
GROUP BY main_category
|
||||
ORDER BY main_category;
|
||||
@@ -0,0 +1,75 @@
|
||||
PRAGMA disable_progress_bar;
|
||||
|
||||
CREATE TABLE products_raw AS
|
||||
SELECT *
|
||||
FROM read_json(
|
||||
getenv('BEAUTY_INPUT'),
|
||||
format = 'newline_delimited',
|
||||
columns = {
|
||||
main_category: 'VARCHAR',
|
||||
title: 'VARCHAR',
|
||||
average_rating: 'DOUBLE',
|
||||
rating_number: 'BIGINT',
|
||||
features: 'VARCHAR[]',
|
||||
description: 'VARCHAR[]',
|
||||
price: 'DOUBLE',
|
||||
images: 'STRUCT(thumb VARCHAR, large VARCHAR, variant VARCHAR, hi_res VARCHAR)[]',
|
||||
videos: 'STRUCT(title VARCHAR, url VARCHAR, user_id VARCHAR)[]',
|
||||
store: 'VARCHAR',
|
||||
categories: 'JSON[]',
|
||||
details: 'MAP(VARCHAR, VARCHAR)',
|
||||
parent_asin: 'VARCHAR',
|
||||
bought_together: 'VARCHAR'
|
||||
}
|
||||
);
|
||||
|
||||
CREATE TABLE products AS
|
||||
SELECT
|
||||
parent_asin,
|
||||
title,
|
||||
store,
|
||||
main_category,
|
||||
average_rating,
|
||||
rating_number,
|
||||
price,
|
||||
details['UPC'] AS upc,
|
||||
(list_filter(images, lambda image: image.variant = 'MAIN'))[1].large AS main_image_url,
|
||||
len(features) AS feature_count,
|
||||
array_to_string(description, ' ') AS description_text
|
||||
FROM products_raw;
|
||||
|
||||
CREATE INDEX products_parent_asin_idx ON products(parent_asin);
|
||||
CREATE INDEX products_store_idx ON products(store);
|
||||
|
||||
CREATE VIEW store_summary AS
|
||||
SELECT
|
||||
store,
|
||||
count(*) AS product_count,
|
||||
round(avg(average_rating), 3) AS mean_product_rating,
|
||||
sum(rating_number) AS rating_count,
|
||||
count(price) AS products_with_price,
|
||||
round(avg(price), 2) AS mean_price
|
||||
FROM products
|
||||
WHERE store IS NOT NULL
|
||||
GROUP BY store;
|
||||
|
||||
CREATE VIEW data_quality AS
|
||||
SELECT
|
||||
count(*) AS records,
|
||||
count(parent_asin) AS records_with_parent_asin,
|
||||
count(DISTINCT parent_asin) AS distinct_parent_asins,
|
||||
count(*) FILTER (WHERE title IS NULL) AS missing_titles,
|
||||
count(*) FILTER (WHERE price IS NULL) AS missing_prices,
|
||||
count(*) FILTER (WHERE average_rating < 0 OR average_rating > 5) AS invalid_ratings,
|
||||
count(*) FILTER (WHERE rating_number < 0) AS negative_rating_numbers,
|
||||
count(*) FILTER (WHERE price < 0) AS negative_prices
|
||||
FROM products;
|
||||
|
||||
CREATE VIEW duplicate_parent_asins AS
|
||||
SELECT parent_asin, count(*) AS records
|
||||
FROM products
|
||||
WHERE parent_asin IS NOT NULL
|
||||
GROUP BY parent_asin
|
||||
HAVING count(*) > 1;
|
||||
|
||||
CHECKPOINT;
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Muthukumaran Navaneethakrishnan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+337
@@ -0,0 +1,337 @@
|
||||
#!/bin/bash
|
||||
# mcpserver_core.sh - Model Context Protocol server core, revision 2026-07-28.
|
||||
#
|
||||
# Implements the stdio binding only (ADR-0001) and the 2026-07-28 revision only
|
||||
# (ADR-0002): no initialize handshake, no sessions, no server-initiated requests.
|
||||
# Every request carries its own protocol version in params._meta.
|
||||
#
|
||||
# This file defines functions and starts nothing. An implementation script sets
|
||||
# the MCP_* paths, sources this file, defines tool_<name> functions, and calls
|
||||
# run_mcp_server.
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# The one protocol revision this server speaks.
|
||||
MCP_PROTOCOL_VERSION="2026-07-28"
|
||||
|
||||
# Configuration paths - overridable by implementations BEFORE sourcing this file.
|
||||
MCP_CONFIG_FILE="${MCP_CONFIG_FILE:-"$SCRIPT_DIR/assets/mcpserverconfig.json"}"
|
||||
MCP_TOOLS_LIST_FILE="${MCP_TOOLS_LIST_FILE:-"$SCRIPT_DIR/assets/tools_list.json"}"
|
||||
MCP_LOG_FILE="${MCP_LOG_FILE:-"$SCRIPT_DIR/mcpserver.log"}"
|
||||
|
||||
# Cache hints for list-style results when the config does not state them.
|
||||
MCP_DEFAULT_TTL_MS="${MCP_DEFAULT_TTL_MS:-60000}"
|
||||
MCP_DEFAULT_CACHE_SCOPE="${MCP_DEFAULT_CACHE_SCOPE:-public}"
|
||||
|
||||
# Field separator used to hand parsed fields from jq back to bash. Unit
|
||||
# Separator (0x1f) cannot appear unescaped inside JSON text.
|
||||
readonly MCP_FS=$'\x1f'
|
||||
|
||||
# ==== Logging =============================================================
|
||||
# stdout carries protocol traffic only, so diagnostics go to a file. Set
|
||||
# MCP_LOG_STDERR=1 to mirror them to stderr, which the spec explicitly allows.
|
||||
|
||||
log() {
|
||||
local level="$1" message="$2"
|
||||
local timestamp
|
||||
timestamp=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
mkdir -p "$(dirname "$MCP_LOG_FILE")"
|
||||
echo "[$timestamp] [$level] $message" >>"$MCP_LOG_FILE"
|
||||
[[ "${MCP_LOG_STDERR:-0}" == "1" ]] && echo "[$level] $message" >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
# Read a JSON file as one compact line. Prints nothing and returns 1 if the
|
||||
# file is missing or malformed, so callers can raise a protocol error instead
|
||||
# of emitting a broken result.
|
||||
read_json_file() {
|
||||
local file_path="$1"
|
||||
if [[ ! -f "$file_path" ]]; then
|
||||
log "ERROR" "Config file not found: $file_path"
|
||||
return 1
|
||||
fi
|
||||
if ! jq -c '.' "$file_path" 2>/dev/null; then
|
||||
log "ERROR" "Config file is not valid JSON: $file_path"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# The server's identity, echoed in every result's _meta. Cached after the first
|
||||
# read so it costs one jq fork per process, not one per response.
|
||||
MCP_SERVER_INFO=""
|
||||
mcp_server_info() {
|
||||
if [[ -z "$MCP_SERVER_INFO" ]]; then
|
||||
MCP_SERVER_INFO=$(jq -c '.serverInfo // empty' "$MCP_CONFIG_FILE" 2>/dev/null)
|
||||
[[ -z "$MCP_SERVER_INFO" ]] && MCP_SERVER_INFO='{"name":"BashMCPServer","version":"0.0.0"}'
|
||||
fi
|
||||
echo "$MCP_SERVER_INFO"
|
||||
}
|
||||
|
||||
# ==== Response construction ==============================================
|
||||
# Built with `jq --arg` rather than string concatenation, so quoting is jq's
|
||||
# problem and a message containing a quote cannot corrupt the envelope.
|
||||
#
|
||||
# The result object arrives on STDIN, never as an argument. Linux caps a single
|
||||
# argv entry at 128 KB (MAX_ARG_STRLEN) regardless of total ARG_MAX, so passing
|
||||
# a large tool result through `--argjson` fails there while working fine on
|
||||
# macOS -- a platform-specific bug that only shows up on big payloads.
|
||||
|
||||
# create_response <id-json> -- result JSON on stdin
|
||||
# Injects the required resultType and the _meta serverInfo the revision expects.
|
||||
create_response() {
|
||||
local id="$1" response
|
||||
|
||||
response=$(jq -c \
|
||||
--argjson id "$id" \
|
||||
--argjson serverInfo "$(mcp_server_info)" '
|
||||
{
|
||||
jsonrpc: "2.0",
|
||||
id: $id,
|
||||
result: (.
|
||||
| .resultType = (.resultType // "complete")
|
||||
| ._meta = ((._meta // {}) + {"io.modelcontextprotocol/serverInfo": $serverInfo}))
|
||||
}') || {
|
||||
log "ERROR" "Failed to build response for id $id"
|
||||
return 1
|
||||
}
|
||||
|
||||
log "RESPONSE" "$response"
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
# create_error_response <id-json> <code> <message> [data-json]
|
||||
create_error_response() {
|
||||
local id="$1" code="$2" message="$3" data="${4:-null}" response
|
||||
|
||||
response=$(jq -cn \
|
||||
--argjson id "$id" \
|
||||
--argjson code "$code" \
|
||||
--arg message "$message" \
|
||||
--argjson data "$data" '
|
||||
{
|
||||
jsonrpc: "2.0",
|
||||
id: $id,
|
||||
error: ({code: $code, message: $message}
|
||||
+ (if $data == null then {} else {data: $data} end))
|
||||
}')
|
||||
|
||||
log "ERROR" "$response"
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
# ==== MCP method handlers ================================================
|
||||
|
||||
# server/discover - a MUST in this revision. Advertises supported protocol
|
||||
# versions, capabilities and cache hints so a client can negotiate without a
|
||||
# handshake. Deliberately exempt from the version gate: this is the method a
|
||||
# client calls precisely because it does not yet know what we speak.
|
||||
handle_discover() {
|
||||
local id="$1" config result
|
||||
|
||||
if ! config=$(read_json_file "$MCP_CONFIG_FILE"); then
|
||||
create_error_response "$id" -32603 "Server configuration unavailable"
|
||||
return
|
||||
fi
|
||||
|
||||
result=$(jq -c \
|
||||
--arg version "$MCP_PROTOCOL_VERSION" \
|
||||
--argjson ttl "$MCP_DEFAULT_TTL_MS" \
|
||||
--arg scope "$MCP_DEFAULT_CACHE_SCOPE" '
|
||||
{
|
||||
supportedVersions: (.supportedVersions // [$version]),
|
||||
capabilities: (.capabilities // {}),
|
||||
ttlMs: (.ttlMs // $ttl),
|
||||
cacheScope: (.cacheScope // $scope),
|
||||
resultType: "complete"
|
||||
}
|
||||
+ (if .instructions then {instructions: .instructions} else {} end)
|
||||
' <<<"$config")
|
||||
|
||||
printf '%s' "$result" | create_response "$id"
|
||||
}
|
||||
|
||||
# tools/list - the tools file stays a plain {"tools":[...]} so authors are not
|
||||
# asked to hand-write cache fields; the core decorates it.
|
||||
handle_tools_list() {
|
||||
local id="$1" tools_doc result
|
||||
|
||||
if ! tools_doc=$(read_json_file "$MCP_TOOLS_LIST_FILE"); then
|
||||
create_error_response "$id" -32603 "Tool list unavailable"
|
||||
return
|
||||
fi
|
||||
|
||||
result=$(jq -c \
|
||||
--argjson ttl "$MCP_DEFAULT_TTL_MS" \
|
||||
--arg scope "$MCP_DEFAULT_CACHE_SCOPE" '
|
||||
{
|
||||
tools: (.tools // []),
|
||||
ttlMs: (.ttlMs // $ttl),
|
||||
cacheScope: (.cacheScope // $scope),
|
||||
resultType: "complete"
|
||||
}' <<<"$tools_doc")
|
||||
|
||||
printf '%s' "$result" | create_response "$id"
|
||||
}
|
||||
|
||||
# tools/call - dispatches to the tool_<name> shell function.
|
||||
#
|
||||
# Error handling follows ADR-0005: a failure *inside* a tool is reported to the
|
||||
# model as a result with isError=true so it can self-correct, while a failure to
|
||||
# *find* the tool is a protocol error.
|
||||
handle_tools_call() {
|
||||
local id="$1" tool_name="$2" arguments="$3"
|
||||
local content status
|
||||
|
||||
log "INFO" "Tool call: $tool_name with arguments: $arguments"
|
||||
|
||||
# Names are validated before dispatch so a call can never resolve to an
|
||||
# arbitrary shell function.
|
||||
if ! [[ "$tool_name" =~ ^[a-zA-Z0-9_]+$ ]]; then
|
||||
create_error_response "$id" -32600 "Invalid tool name format: $tool_name"
|
||||
return
|
||||
fi
|
||||
|
||||
if ! type "tool_${tool_name}" &>/dev/null; then
|
||||
create_error_response "$id" -32602 "Tool not found: $tool_name"
|
||||
return
|
||||
fi
|
||||
|
||||
content=$("tool_${tool_name}" "$arguments")
|
||||
status=$?
|
||||
|
||||
# Tool output goes to jq on STDIN, not through --arg: it can be arbitrarily
|
||||
# large and Linux rejects any single argv entry over 128 KB.
|
||||
# `-R -s` slurps it as one raw string, escaping newlines as \n inside the
|
||||
# JSON string -- satisfying the transport's no-embedded-newline rule without
|
||||
# destroying the formatting.
|
||||
if [[ $status -ne 0 ]]; then
|
||||
log "INFO" "Tool $tool_name reported failure (exit $status)"
|
||||
[[ -z "$content" ]] && content="Tool '$tool_name' failed with exit status $status"
|
||||
printf '%s' "$content" \
|
||||
| jq -cRs '{content: [{type: "text", text: .}], isError: true, resultType: "complete"}' \
|
||||
| create_response "$id"
|
||||
return
|
||||
fi
|
||||
|
||||
printf '%s' "$content" \
|
||||
| jq -cRs '{content: [{type: "text", text: .}], resultType: "complete"}' \
|
||||
| create_response "$id"
|
||||
}
|
||||
|
||||
# ==== Message processing =================================================
|
||||
|
||||
# Parse one message with a single jq invocation (ADR-0004). Field order:
|
||||
# jsonrpc | id | method | protocolVersion | toolName | arguments
|
||||
# `id` is empty when the key is absent, which is how a notification is
|
||||
# distinguished from a request whose id is literally null.
|
||||
parse_message() {
|
||||
jq -j '
|
||||
# Raw newlines would truncate the bash `read` below. Scalars are
|
||||
# squashed to spaces; the arguments blob is safe already because
|
||||
# tojson escapes newlines as the two characters \ and n.
|
||||
def str(v): (v // "") | tostring | gsub("[\n\r]"; " ");
|
||||
[ str(.jsonrpc),
|
||||
(if has("id") then (.id | tojson) else "" end),
|
||||
str(.method),
|
||||
str(.params?._meta?["io.modelcontextprotocol/protocolVersion"]?),
|
||||
str(.params?.name?),
|
||||
((.params?.arguments? // {}) | tojson)
|
||||
] | join("\u001f")
|
||||
' 2>/dev/null
|
||||
}
|
||||
|
||||
process_request() {
|
||||
local input="$1"
|
||||
local fields jsonrpc id method protocol_version tool_name arguments
|
||||
|
||||
# A blank line is not a message.
|
||||
[[ -z "${input//[[:space:]]/}" ]] && return 0
|
||||
|
||||
log "REQUEST" "$input"
|
||||
|
||||
if ! fields=$(parse_message <<<"$input"); then
|
||||
create_error_response "null" -32700 "Parse error: input is not valid JSON"
|
||||
return
|
||||
fi
|
||||
|
||||
IFS="$MCP_FS" read -r jsonrpc id method protocol_version tool_name arguments <<<"$fields"
|
||||
|
||||
# No id means a notification: fire-and-forget, never answered - not even
|
||||
# to report that it was malformed.
|
||||
if [[ -z "$id" ]]; then
|
||||
log "INFO" "Notification received: ${method:-<none>}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log "INFO" "Processing method: $method (id: $id, protocolVersion: ${protocol_version:-<none>})"
|
||||
|
||||
if [[ "$jsonrpc" != "2.0" ]]; then
|
||||
create_error_response "$id" -32600 "Invalid Request: Not a JSON-RPC 2.0 request"
|
||||
return
|
||||
fi
|
||||
|
||||
# server/discover is how a client learns which versions exist, so gating it
|
||||
# on the version would deadlock negotiation.
|
||||
if [[ "$method" == "server/discover" ]]; then
|
||||
handle_discover "$id"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$protocol_version" != "$MCP_PROTOCOL_VERSION" ]]; then
|
||||
create_error_response "$id" -32022 \
|
||||
"Unsupported protocol version: ${protocol_version:-<missing>}" \
|
||||
"$(jq -cn --arg requested "$protocol_version" --arg supported "$MCP_PROTOCOL_VERSION" \
|
||||
'{requested: $requested, supported: [$supported]}')"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$method" in
|
||||
"tools/list")
|
||||
handle_tools_list "$id"
|
||||
;;
|
||||
"tools/call")
|
||||
handle_tools_call "$id" "$tool_name" "$arguments"
|
||||
;;
|
||||
*)
|
||||
create_error_response "$id" -32601 "Method not found: $method"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# === Error codes ==========================================================
|
||||
#
|
||||
# JSON-RPC standard:
|
||||
# -32700 Parse error - input was not valid JSON
|
||||
# -32600 Invalid Request - not a JSON-RPC 2.0 message, or a bad tool name
|
||||
# -32601 Method not found
|
||||
# -32602 Invalid params - includes "tool not found" and, per this
|
||||
# revision, "resource not found" (moved from -32002)
|
||||
# -32603 Internal error - server-side failure, e.g. unreadable config
|
||||
#
|
||||
# Allocation policy (2026-07-28):
|
||||
# -32000..-32019 implementation-defined; existing SDK usage grandfathered
|
||||
# -32020..-32099 reserved for the specification:
|
||||
# -32020 HeaderMismatch (HTTP transport only)
|
||||
# -32021 MissingRequiredClientCapability
|
||||
# -32022 UnsupportedProtocolVersion - data: {requested, supported[]}
|
||||
#
|
||||
# Tool-level failures are NOT protocol errors: they come back as a successful
|
||||
# result with isError=true so the model can see and correct them (ADR-0005).
|
||||
|
||||
# ==== Main loop ===========================================================
|
||||
run_mcp_server() {
|
||||
if ! command -v jq &>/dev/null; then
|
||||
echo "Error: jq is required but not installed. Install it using: brew install jq" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "INFO" "MCP server started (protocol $MCP_PROTOCOL_VERSION, stdio transport)"
|
||||
|
||||
local line response
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
response=$(process_request "$line")
|
||||
[[ -n "$response" ]] && echo "$response"
|
||||
done
|
||||
|
||||
log "INFO" "stdin closed; exiting"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"simple-beauty": {
|
||||
"type": "local",
|
||||
"command": [
|
||||
"bash",
|
||||
"simple-duckdb-mcp.sh"
|
||||
],
|
||||
"cwd": ".",
|
||||
"protocol": "2026-07-28",
|
||||
"codemode": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE OR REPLACE TABLE products AS
|
||||
SELECT
|
||||
parent_asin,
|
||||
title,
|
||||
store,
|
||||
average_rating,
|
||||
rating_number,
|
||||
price,
|
||||
details['UPC'] AS upc
|
||||
FROM read_json_auto(
|
||||
'meta_All_Beauty.jsonl',
|
||||
format = 'newline_delimited',
|
||||
sample_size = -1
|
||||
);
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"supportedVersions": ["2026-07-28"],
|
||||
"serverInfo": {
|
||||
"name": "simple-beauty-duckdb",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"capabilities": {
|
||||
"tools": {
|
||||
"listChanged": false
|
||||
}
|
||||
},
|
||||
"instructions": "Use the fixed read-only tools to report Beauty dataset counts, prices, and top stores. Never claim a result without calling the tool."
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"tools": [
|
||||
{
|
||||
"name": "product_count",
|
||||
"description": "Count products and unique product IDs",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "price_summary",
|
||||
"description": "Report price availability, average price, and median price",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "top_stores",
|
||||
"description": "List the ten stores with the most products",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
.mode box
|
||||
|
||||
SELECT
|
||||
count(*) AS products,
|
||||
count(DISTINCT parent_asin) AS unique_products,
|
||||
count(price) AS products_with_price,
|
||||
round(avg(price), 2) AS average_price
|
||||
FROM products;
|
||||
|
||||
SELECT
|
||||
store,
|
||||
count(*) AS products,
|
||||
round(avg(average_rating), 2) AS average_rating
|
||||
FROM products
|
||||
WHERE store IS NOT NULL
|
||||
GROUP BY store
|
||||
ORDER BY products DESC, store
|
||||
LIMIT 10;
|
||||
Reference in New Issue
Block a user