PHPackages                             chrisjohnleah/sage-business-cloud-accounting-mcp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. chrisjohnleah/sage-business-cloud-accounting-mcp

ActiveLibrary[API Development](/categories/api)

chrisjohnleah/sage-business-cloud-accounting-mcp
================================================

Model Context Protocol (MCP) server for the Sage Business Cloud Accounting API — exposes Sage accounting data and actions as tools for AI agents.

v0.3.0(1mo ago)001MITPHPPHP ^8.3CI passing

Since Jun 14Pushed 1mo agoCompare

[ Source](https://github.com/chrisjohnleah/sage-business-cloud-accounting-mcp)[ Packagist](https://packagist.org/packages/chrisjohnleah/sage-business-cloud-accounting-mcp)[ Docs](https://github.com/chrisjohnleah/sage-business-cloud-accounting-mcp)[ RSS](/packages/chrisjohnleah-sage-business-cloud-accounting-mcp/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

Sage Business Cloud Accounting — MCP Server
===========================================

[](#sage-business-cloud-accounting--mcp-server)

[![CI](https://github.com/chrisjohnleah/sage-business-cloud-accounting-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/chrisjohnleah/sage-business-cloud-accounting-mcp/actions/workflows/ci.yml)[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

A [Model Context Protocol](https://modelcontextprotocol.io) server for the Sage Business Cloud Accounting API. It exposes Sage accounting data and actions as **tools an AI agent can call** (Claude Desktop, Claude Code, or any MCP client) — built directly on top of [`chrisjohnleah/sage-business-cloud-accounting-api`](https://github.com/chrisjohnleah/sage-business-cloud-accounting-api), so token refresh, pagination, and typed resources come for free.

> An MCP server is a **tool provider** — the AI model lives in the client. This package needs no AI/LLM SDK of its own.

This is a sibling to:

- [`sage-business-cloud-accounting-api`](https://github.com/chrisjohnleah/sage-business-cloud-accounting-api) — the framework-agnostic PHP SDK (this package depends on it).
- [`sage-business-cloud-accounting-api-laravel`](https://github.com/chrisjohnleah/sage-business-cloud-accounting-api-laravel) — the Laravel bridge.

Requirements
------------

[](#requirements)

- PHP 8.3+
- A Sage Developer app ()

Installation
------------

[](#installation)

```
composer require chrisjohnleah/sage-business-cloud-accounting-mcp
```

Configuration
-------------

[](#configuration)

The server reads its configuration from the environment:

```
SAGE_CLIENT_ID=...
SAGE_CLIENT_SECRET=...
SAGE_REDIRECT_URI=https://your-app.test/oauth/sage/callback
SAGE_SCOPES=readonly                 # or full_access

# Optional — where the OAuth token is cached.
# Defaults to ~/.config/sage-mcp/token.json
SAGE_MCP_TOKEN_PATH=/absolute/path/to/token.json
```

The token is cached as a single JSON file (see `FileTokenStore`), so the server is fully self-contained — no database required.

Connecting (one-time OAuth)
---------------------------

[](#connecting-one-time-oauth)

Authorise the server against your Sage account once. The token is cached via `FileTokenStore` and refreshed automatically on every subsequent call.

```
# Reads the same SAGE_* environment variables as the server.
php vendor/bin/sage-mcp connect
```

By default `connect` uses an **RFC 8252 loopback redirect** — the same pattern `gcloud auth login` and `gh auth login` use. It starts a temporary listener on `http://127.0.0.1:8765/callback`, opens your browser, and catches the authorization code there automatically. The redirect never touches a production web callback, and there is nothing to copy-paste. (Claude Code does not broker OAuth for stdio MCP servers, so the server owns this flow.)

> **From inside your MCP client:** you don't need a terminal — just invoke the **`sage_connect`** tool (e.g. ask the agent to "connect to Sage"). It runs the same loopback flow, opens your browser, and saves the token. Call it whenever a Sage tool reports it's not connected.

**One-time setup:** register the loopback redirect URI **exactly** in your Sage Developer app (Sage requires an exact match):

```
http://127.0.0.1:8765/callback

```

Change the port with `--port=N` or `SAGE_MCP_CALLBACK_PORT` (register a matching URI). To enable the write tools, set `SAGE_SCOPES=full_access` before connecting (see [Tools](#tools)). After connecting, the cached token refreshes automatically.

**Alternatives**

```
php vendor/bin/sage-mcp connect --manual         # print URL, paste the redirect URL/code back
php vendor/bin/sage-mcp connect ""   # exchange a code non-interactively
```

`--manual` uses your configured `SAGE_REDIRECT_URI` instead of the loopback.

Registering with an MCP client
------------------------------

[](#registering-with-an-mcp-client)

Add the server to your client's MCP config (Claude Desktop example):

```
{
  "mcpServers": {
    "sage": {
      "command": "php",
      "args": ["/absolute/path/to/vendor/bin/sage-mcp"],
      "env": {
        "SAGE_CLIENT_ID": "...",
        "SAGE_CLIENT_SECRET": "...",
        "SAGE_REDIRECT_URI": "...",
        "SAGE_SCOPES": "readonly"
      }
    }
  }
}
```

Tools
-----

[](#tools)

All tools operate on the connected business (see [Connecting](#connecting-one-time-oauth)). Results are returned as JSON.

**Read — always available:**

ToolDescription`list_contacts`List contacts (customers and suppliers). Filters: `updated_or_created_since`, `search`, `email`, `contact_type_id`, `limit`.`list_purchase_invoices`List purchase (supplier) invoices. Filters: `updated_or_created_since`, `status_id`, `contact_id`, `from_date`, `to_date`, `limit`.`get_business`Get the connected business (id, name, address, contact details).`sage_connect`Authenticate/re-authenticate to Sage (opens your browser, loopback OAuth). Call this if a tool reports it's not connected.**Write — only registered when `SAGE_SCOPES=full_access`:**

ToolDescription`create_contact`Create a contact. Required: `name`, `contact_type_id` (`CUSTOMER` or `VENDOR`). Optional: `reference`, `email`, `tax_number`, `notes`.`create_purchase_invoice`Create a purchase (supplier) invoice. Required: `contact_id`, `date`, `invoice_lines`. Optional: `due_date`, `reference`, `vendor_reference`, `notes`.Write tools are omitted from the tool list entirely unless `full_access` is in `SAGE_SCOPES`, so a read-only deployment can never mutate Sage data.

Testing
-------

[](#testing)

```
composer check   # Pint + PHPStan (max) + Pest
```

Licence
-------

[](#licence)

MIT © [Chris John Leah](https://github.com/chrisjohnleah). See [LICENSE](LICENSE).

> Not affiliated with or endorsed by The Sage Group plc.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec2ce54c81968f6fc293587599bbaaa4221e303eec07cd2a50de1d99a6f0f2a4?d=identicon)[chrisjohnleah](/maintainers/chrisjohnleah)

---

Top Contributors

[![chrisjohnleah](https://avatars.githubusercontent.com/u/959104?v=4)](https://github.com/chrisjohnleah "chrisjohnleah (5 commits)")

---

Tags

apimcpaiAccountingagentssageModel Context Protocolsage-business-cloud

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chrisjohnleah-sage-business-cloud-accounting-mcp/health.svg)

```
[![Health](https://phpackages.com/badges/chrisjohnleah-sage-business-cloud-accounting-mcp/health.svg)](https://phpackages.com/packages/chrisjohnleah-sage-business-cloud-accounting-mcp)
```

###  Alternatives

[wordpress/mcp-adapter

Adapter for Abilities API, letting WordPress abilities to be used as MCP tools, resources or prompts

887184.7k8](/packages/wordpress-mcp-adapter)[php-mcp/laravel

Laravel SDK for building Model Context Protocol (MCP) servers - Seamlessly integrate MCP tools, resources, and prompts into Laravel applications

473153.0k4](/packages/php-mcp-laravel)[vizra/vizra-adk

Vizra Agent Development Kit - A comprehensive Laravel package for building intelligent AI agents.

29434.2k](/packages/vizra-vizra-adk)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

46688.8k5](/packages/deepseek-php-deepseek-php-client)[alle-ai/anthropic-api-php

The go-to PHP library for the Anthropic API — Messages, streaming, tool use, vision, prompt caching, extended thinking, MCP, Files, Batches. Maintained by Alle-AI.

2626.6k](/packages/alle-ai-anthropic-api-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
