No Browser Needed: I Turned My Masterless Laravel 12 B2B OSS Into an Official MCP Server
Introduction: A Casual Chat With My Coding AI Turned Into a Production MCP Server in 3 Hours
In my previous DEV article, I turned my AI employee alisa - running on a vintage 2010 Celeron laptop with OpenClaw and Gemini Flash Lite - into a white-hat Red Teamer to pentest my open-source Laravel 12 B2B ordering platform, MESHu.
Before that, whenever I wanted alisa to check quotes or simulate real B2B orders, she had to write custom Python scripts to log in, extract CSRF tokens, and parse HTML forms. It worked, but it was fragile: any UI tweak could break it, and no other company's AI agent could reuse it.
Then, during a casual chat with my development AI assistant (Antigravity), I threw out a simple question:
Me: "Could we build anything useful in MESHu using MCP (Model Context Protocol)?"
AI: "It's an incredible match! Because MESHu is masterless (free-text) and built on a mirrored shared ledger, it fits AI agents + MCP far better than traditional B2B ERPs that choke on rigid product-code lookups."
As we talked through it, it genuinely felt as if MESHu's network architecture had been designed for MCP from day one.
I said "Let's build it!" - and within a few hours, using Laravel's first-party laravel/mcp package and laravel/sanctum, MESHu became an official Read-Only MCP server live in production at https://meshu.org/mcp, tested end-to-end by alisa on her 15-year-old Celeron laptop.
Now, users don't even have to open MESHu in a browser. They can simply ask Claude, ChatGPT, Gemini, or their own local AI agent:
- "Did any customer send a new quote request today?"
- "How much did we quote for Precision Industrial Part Type-A last time?"
And MESHu answers directly over MCP - with zero AI vendor lock-in and zero AI API cost on the platform side.
Why Make the B2B App an MCP Server (Instead of Embedding an AI Chat)?
There are two ways to add AI to a SaaS or OSS platform:
- Embed an AI chat inside the web UI (App calls LLM APIs) - Forces the platform operator (or self-hoster) to manage LLM API keys, pay token bills, and chase fast-moving models.
- Expose the app as a neutral MCP Server (Bring Your Own AI) - Every company connects whichever AI they already pay for or self-host (Claude, ChatGPT, Cursor, or a local LLM on a 15-year-old laptop).
For a free, open-source (AGPLv3) B2B ordering protocol, option 2 fits like a glove.
Even better, MESHu's core architecture turned out to be unexpectedly AI-native:
- Masterless (free-text) line items: Traditional B2B ERPs choke AI agents with strict SKU/product-code lookups. Masterless data is naturally searchable by LLMs.
- Mirrored shared ledger: Buyer and seller share the exact same source of truth.
- 3-layer zero-trust scoping: Company + assigned-partner permissions map cleanly onto Sanctum Bearer tokens.
Architecture: Phase 1 (Read-Only MCP + 3-Layer Zero-Trust)
Giving an AI write access to place real B2B purchase orders on day one is reckless. So Phase 1 is strictly Read-Only, with every tool marked with #[IsReadOnly].
1. Installing laravel/mcp & laravel/sanctum
docker compose exec app composer require laravel/mcp laravel/sanctum
docker compose exec app php artisan vendor:publish --tag=ai-routes
docker compose exec app php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
docker compose exec app php artisan migrate
2. Exposing /mcp Behind auth:sanctum (routes/ai.php)
<?php
use App\Mcp\Servers\MeshuServer;
use Laravel\Mcp\Facades\Mcp;
Mcp::web('/mcp', MeshuServer::class)->middleware(['auth:sanctum']);
Any unauthenticated POST to /mcp is immediately rejected with 401 Unauthorized.
3. Enforcing 3-Layer Zero-Trust Across All Tools (McpAccessScope)
Every MCP tool calls a single shared scope resolver (App\Mcp\Support\McpAccessScope) so an AI token can never see more than the human user who issued it:
public static function allowedLinkIds(User $user, Company $company): array
{
$companyId = (int) $company->id;
$query = CompanyLink::query()->where('status', 'approved')->where(function ($q) use ($companyId): void {
$q->where('buyer_company_id', $companyId)->orWhere('seller_company_id', $companyId);
});
// Non-admin staff without full access can only see their assigned partner links
$isAllAssigned = ($user->role === 'admin' || (int) $user->is_all_assigned === 1);
if (!$isAllAssigned) {
$assignedIds = UserAssignedLink::query()->where('user_id', (int) $user->id)->pluck('company_link_id')->map(static fn ($id): int => (int) $id)->all();
if ($assignedIds === []) {
return [];
}
$query->whereIn('id', $assignedIds);
}
return $query->pluck('id')->map(static fn ($id): int => (int) $id)->all();
}
4. The 3 Read-Only MCP Tools
list_linked_companies- Lists approved buyer/seller partner companies within the user's permission scopelist_pending_transactions- Retrieves open quote requests, replied quotes, and pending orderssearch_past_quotes- Searches historical item names, specs, quantities, and unit prices across past transactions
Real-World Multi-Tenant Details That Mattered
While building and testing on both staging and production, a few real-world details stood out:
Self-Service Token UI in /profile (with IDOR Protection)
Users can generate (shown once) and revoke up to 10 mcp:read tokens right from their profile page, complete with last_used_at tracking. Revocation is strictly scoped to $user->tokens()->where('id', $tokenId)->delete() - verified by an automated IDOR attack test.
Multi-Tenant CLI Safety (url_code + email)
Because the same email can exist across different tenant companies in MESHu, the CLI issuer requires both url_code and email:
php artisan meshu:mcp-token <url_code> <email> --name=alisa-mcp
LAN HTTP Clipboard Fallback for Self-Hosters
Many SMBs self-host OSS tools on internal HTTP LANs where navigator.clipboard is disabled by browsers. Adding an automatic document.execCommand('copy') fallback fixed one-click token copying on non-HTTPS LAN setups.
Automated Test Suite
Added 5 dedicated Feature tests (unauthenticated 401 rejection, 3-tool execution, cross-tenant + unassigned-partner data isolation, self-service token lifecycle, and IDOR revocation defense). Full test suite: 205 passed (1,008 assertions).
Live Connection Test: Our 15-Year-Old Celeron AI Employee Connects Over MCP
To keep production credentials completely private while capturing screenshots, I spun up a fresh git clone of the public MESHu-OSS repository on an internal local VM (http://mshoss:8080/mcp), issued a temporary Read-Only token from the profile screen (revoked immediately after testing), and handed it to alisa on her 2010 Celeron laptop.
Zero Python scripts written. Within seconds, alisa called tools/list, queried list_linked_companies, list_pending_transactions, and search_past_quotes, and reported back with both the latest pending quote request (#19) and a full 6-month historical unit price breakdown (¥7,727 / unit on Nov 26, #18).
And cross-checking with the actual MESHu ledger screen (Transaction #18), every single yen (¥7,727.00 × 100 = ¥772,727) matched 100%.
It worked on the very first try with zero extra configuration on a clean OSS clone - and the exact same code is also live and verified in production at https://meshu.org/mcp.
What's Next: Phase 2 (Human-in-the-Loop Drafts)
With Read-Only MCP live in production, MESHu now offers two equal doors to the same neutral B2B ledger:
- A clean, masterless Web UI for humans (mobile-friendly, no app install required)
- An official MCP Server (
/mcp) for any AI agent
Next up is Phase 2: letting AI agents prepare draft quotes or orders from voice memos or chat messages, while keeping the final "Send" click strictly in human hands (Human-in-the-Loop).
Everything is open source under AGPLv3 - clone it with Docker and connect your own AI agent in minutes: meshuoffice / MESHu-OSS
特定の企業に運営を独占させない。中立な非営利技術コンソーシアム運営を目指す、オープンソースのB2B取引プラットフォーム。 🌐 日本語 | English MESHu (B2B Transaction Platform) 誰もデータを独占せず、特定の1社に覗かせない。 中立な非営利技術コンソーシアム運営を目指す、オープンソースのB2B取引プラットフォーム。 操作デモ動画 • プロジェクト理念 • 機能一覧 • クイックスタート • セキュリティ • パートナー募集 • ドキュメント • 公式 𝕏 (@meshu_org) 🎬 実画面操作デモ(3分半) 買手(株式会社サンプル商事)と売手(株式会社テスト販売)の2社間で、事前商品マスタ登録なしの見積依頼〜見積回答〜正式注文〜受注承諾(取引成立)までが1本の「共有原簿」上で完結する操作デモ動画です。 ▶ YouTube で実画面操作デモを見る(3分28秒) 💡 プロジェクト理念 (The MESHu Philosophy) 1. 「特定の1社がデータを覗き見たり、独占して利益を貪る構造にしない」 企業間取引データ(見積条件、受発注履歴、単価、チャットでの商談)は、各企業にとって最も重要な機密情報です。 従来の商用SaaSでは、プラットフォーム運営企業にデータが集約され、将来的な利用料の引き上げやデータの囲い込み・二次利用といった構造的リスクが存在していました。 MESHu は、特定の営利企業が取引データを私物化したり独占することを拒否し、 「公共のデジタル公道(インフラ)」 として機能することを目指しています。 2. 「非営利の技術コンソーシアム」による中立運営 MESHu は、将来的には参加企業や業界団体が共同で管理・相互監視する 非営利の技術コンソーシアム(一般社団法人等) による運営を志向しています(ドメインに .org を採用している理由もここにあります)。 誰か1社の恣意的な判断でルールが変えられたり、サービスが打ち切られることのない、永続的で中立な取引基盤を提供します。 3. 「健全な運営体制を維持し、余剰金はセキュリティと堅牢性へ積極投資」 MESHu は株主配当や役員報酬のための利益追求を行いません。 プラットフォームの維持分担金や賛助金として得られた資金は、 健全で持続可能な運営・保守体制の維持を最優先としつつ、余剰金は積極的にセキュリティ対策(WAF多重防御、第三者機関による侵入診断、改ざん防止監査ログ、暗号化、災害対策)へ再投資 されます。 利益を削ってセキュリティを妥協する商業ツールとは一線を画す、圧倒的な堅牢性を実現します。 🌟 主な機能 🤝 つながり管理 (Company Links) : 取引先企業の検索、連携申請・承認、担当者ごとの権限割当 📑 取引管理 (Transactions) : 見積依頼、見積回答、注文、受注承諾、適格請求書(インボイス)対応、端数処理・消費税計算、各種帳票ブラウザ印刷(A4対応) 💬 企業間チャット (Chats) : 取引先との1対1リアルタイムメッセージ、ファイル添付(最大20MB)、既読管理、厳格な担当者振り分け通知メール 📢 お知らせ機能 (Notices) : 事務局連絡、取引先発信業務連絡、自社お知らせ配信管理 📚 マニュアル・ヘルプ (Manual & Help) : システム操作マニュアル、FAQ(よくある質問)、企業退会申請・データ保護フロー 🏢 マルチテナント企業認証 : 企業専用URL( /{url_code}/login )、SHA-256トークンによるセキュアなパスワード再設定 🚀 クイックスタート (Docker) Docker がインストールされた環境であれば、以下のコマンドだけで数分でローカル環境が立ち上がります。
# 1. リポジトリのクローン
git clone https://github.com/meshuoffice/MESHu-OSS.git
cd MESHu-OSS
# 2. 環境変数設定ファイルの配置
cp src/.env.example src/.env
# 3. コンテナのビルド・起動 (Nginx, PHP 8.2, PostgreSQL 16, Mailpit)
docker compose up -d
# 4. 依存ライブラリのインストール & 暗号化キー生成
docker exec meshu-laravel-app composer install
docker exec meshu-laravel-app php artisan key:generate
# 5. マイグレーション
View on GitHub
Official Portal : https://meshu.org
Official MCP Endpoint (Read-Only) : https://meshu.org/mcp
3.5-Min Live Demo (YouTube) : https://www.youtube.com/watch?v=cbzC-S_i_7c
X / Twitter : https://x.com/meshu_org
Comments
No comments yet. Start the discussion.