Skip to content

feat(bling): add 6 new tools for order details, stores, statuses, products and warehouses - #179

Merged
rapguit merged 4 commits into
codespar:mainfrom
CalmEsSimple:main
Jul 13, 2026
Merged

feat(bling): add 6 new tools for order details, stores, statuses, products and warehouses#179
rapguit merged 4 commits into
codespar:mainfrom
CalmEsSimple:main

Conversation

@CalmEsSimple

Copy link
Copy Markdown
Contributor

feat(bling): add 6 new tools for order details, stores, statuses, products and warehouses

Summary

This PR adds 6 new tools to the Bling MCP server that were missing and are needed for common sales analytics and inventory workflows.

New tools

get_order

Fetches a single sales order by ID including full line items (products, SKUs, quantities, prices).

Why: list_orders returns order summaries without items. The only way to get SKU-level data is via GET /pedidos/vendas/{id}.

list_orders_with_items

Fetches all orders in a date range with full item details. Handles pagination and rate limiting (3 req/sec) internally. Returns results in pages (batchPage/batchSize) to avoid MCP timeouts.

Why: Getting SKU-level sales analytics requires fetching N orders individually. This tool handles that complexity internally so the caller gets a single clean result.

list_stores

Lists all sales channels (lojas/canais de venda) with IDs and names.

Why: list_orders returns loja.id but no name. Without this tool there's no way to know which channel is which.

list_order_statuses

Resolves one or more situacao IDs to their names. Calls GET /situacoes/{id} for each ID.

Why: Orders have custom status IDs (e.g. 280721, 468042) with no obvious names. This tool resolves them on demand.

get_product

Fetches full product details by ID, including variations, stock info, pricing, dimensions, and supplier data.

Why: list_products returns a summary. Full product details (cost price, variations, supplier) require GET /produtos/{id}.

list_warehouses

Lists all warehouses (depósitos) with IDs, names, and whether they count toward virtual stock.

Why: get_stock returns stock broken down by deposito.id but no names. This tool resolves them. Also exposes the desconsiderarSaldo flag which determines whether a warehouse counts toward virtual stock totals.

Notes

  • All new tools follow the same patterns as existing tools (no new dependencies, same error handling)
  • list_orders_with_items uses batchPage/batchSize pagination to stay within MCP request timeouts while respecting the 3 req/sec rate limit
  • Tested against production Bling API v3

# feat(bling): add 6 new tools for order details, stores, statuses, products and warehouses

## Summary

This PR adds 6 new tools to the Bling MCP server that were missing and are needed for common sales analytics and inventory workflows.

## New tools

### `get_order`
Fetches a single sales order by ID including full line items (products, SKUs, quantities, prices).

**Why:** `list_orders` returns order summaries without items. The only way to get SKU-level data is via `GET /pedidos/vendas/{id}`.

### `list_orders_with_items`
Fetches all orders in a date range with full item details. Handles pagination and rate limiting (3 req/sec) internally. Returns results in pages (`batchPage`/`batchSize`) to avoid MCP timeouts.

**Why:** Getting SKU-level sales analytics requires fetching N orders individually. This tool handles that complexity internally so the caller gets a single clean result.

### `list_stores`
Lists all sales channels (lojas/canais de venda) with IDs and names.

**Why:** `list_orders` returns `loja.id` but no name. Without this tool there's no way to know which channel is which.

### `list_order_statuses`
Resolves one or more `situacao` IDs to their names. Calls `GET /situacoes/{id}` for each ID.

**Why:** Orders have custom status IDs (e.g. 280721, 468042) with no obvious names. This tool resolves them on demand.

### `get_product`
Fetches full product details by ID, including variations, stock info, pricing, dimensions, and supplier data.

**Why:** `list_products` returns a summary. Full product details (cost price, variations, supplier) require `GET /produtos/{id}`.

### `list_warehouses`
Lists all warehouses (depósitos) with IDs, names, and whether they count toward virtual stock.

**Why:** `get_stock` returns stock broken down by `deposito.id` but no names. This tool resolves them. Also exposes the `desconsiderarSaldo` flag which determines whether a warehouse counts toward virtual stock totals.

## Notes

- All new tools follow the same patterns as existing tools (no new dependencies, same error handling)
- `list_orders_with_items` uses `batchPage`/`batchSize` pagination to stay within MCP request timeouts while respecting the 3 req/sec rate limit
- Tested against production Bling API v3

@rapguit rapguit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution — the Bling code itself is genuinely well-engineered. list_orders_with_items in particular handles the SKU-aggregation problem nicely (batched Promise.allSettled pairs, 700ms throttle to stay under the 3 req/sec ceiling, batchPage / hasMore to avoid MCP timeouts). list_order_statuses doing per-id allSettled so a single failure doesn't tank the batch is also the right call.

Three things to address before this can land:

  1. 🚨 Root package.json rewrite is unmergeable. The current diff rewrites the monorepo's root package.json into a standalone single-package shape — renaming mcp-dev-latam@calmessimple/mcp-bling, removing private: true, deleting the entire workspaces array, dropping the audit scripts + repo URL, adding mcpName: io.github.calmessimple/.... Merging that would destroy the monorepo for every other server in the catalog. Looks like spillover from developing locally as a standalone fork — please revert package.json entirely (leave it identical to main). If your goal is also to publish a personal fork on npm, that's totally fine, but it has to live in your own repo, not in the root of this one.

  2. MANAGED_TIER_HINT is removed in packages/erp/bling/src/index.ts — the instructions: MANAGED_TIER_HINT argument on new Server(...). This hint ships in ~115 servers across the catalog; it's the standard pattern. Looks like an artifact of an older base branch (the hint was added after you forked). Please restore the constant + the instructions argument.

  3. Tool count mismatch. The PR body advertises 6 tools (the 6th being list_warehouses), but the code only ships 5 (get_product, list_orders_with_items, get_order, list_order_statuses, list_stores). Either list_warehouses was meant to be in the diff and got lost, or the body needs to drop that section. Either is fine — just let me know which.

Once (1) and (2) are addressed (and the count in (3) reconciled), I'll re-review and merge. The Bling additions are good and worth landing.

# Conflicts:
#	package.json
#	packages/erp/bling/src/index.ts

@rapguit rapguit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these Bling tools, @CalmEsSimple — genuinely well-engineered, and a great first PR. list_orders_with_items handling SKU aggregation with throttled Promise.allSettled is a nice touch. I applied the three requested changes to land it: reverted the root package.json to keep the monorepo workspaces intact (a standalone npm fork is totally fine — it just lives in your own repo), restored the managed-tier hint, and reconciled the tool count — list_warehouses already exists upstream, so your 5 new tools bring bling to 39. CI is green. One efficiency follow-up (non-blocking) on the batch re-fetch — filing a tracked issue. 🚀

@rapguit
rapguit merged commit d589eb6 into codespar:main Jul 13, 2026
3 checks passed
@rapguit

rapguit commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Filed the efficiency follow-up as #219 (the batch re-fetch in list_orders_with_items) — non-blocking, but tracked. Thanks again for the contribution! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants