Symfony AI × PHP MCP SDK

Find the right tools. Follow the team’s procedure.

We started with a question. As a Symfony app grows, why should an agent read every tool definition before it can answer a user? Our MCP catalog starts with just search_tools and execute_tools. The agent looks up what it needs and calls it.

Finding a tool answers “what can I call?” A team procedure answers “what should I do next?” We prototyped the MCP working group’s named Groups draft so a team can publish instructions alongside the tools for a job. A client can follow them call by call, or write a program that passes one result into the next. Symfony runs its existing handlers and checks each read. The application needs no sandbox.

The agent opens the team’s refund Group, checks the policy for R-1042 and recommends manual review. When it tries the same procedure for R-1043, Symfony denies the order read.Read the transcriptTry the same questionsInspect the JavaScript proof

Architecture

One tool, or a team procedure?

Find the tools for the job

The client starts with two tool definitions, even in our 128-tool test catalog. It uses search_tools to find the readers available to this user. See the startup measurement

Open a Group

A Group pairs the team’s instructions with the tool definitions they use. In the film, opening refund-review tells the agent where to start: read the order, then look up the policy named on it.

Follow the procedure

The agent calls both readers through execute_tools. Symfony checks access each time. When the user asks about a second order, Symfony denies that read.

Follow the calls in Symfony Profiler

Six MCP requests in order: list tools, find the refund Group, open it, read the order, read its policy, then fail to read the second order.
In this PHP MCP SDK replay, search finds and opens refund-review. Execution reads R-1042 and its policy. The last request also returns HTTP 200, but the tool reports a denial for R-1043. Open the full-size trace

Why did Symfony deny the last read?

The agent had already found the order reader. When it asked for R-1043, Symfony checked whether the user could read that order. In the diagram, follow the catalog route to the permission check: the denial goes back to the client before the PHP handler runs.

Scroll across the diagram or open it full size.

A client finds and opens a procedure through the catalog or negotiated Groups methods. Both paths check each read before the Symfony AI Toolbox invokes the handler. Pink diamonds mark this project’s additions and purple squares mark upstream components.

The second route shows how a client that supports the Groups draft can reach those same readers. Read the Groups proposal ↗

How one read feeds the next

Which refund policy applies? The order itself supplies the answer. In this recorded run, Claude’s JavaScript reads the order, then passes its policyId straight into the policy lookup. Symfony checks the caller’s access on both reads.

Order reader returned
policyId standard-eu
Claude’s JavaScript
ov.policyId
Policy reader received
policyId standard-eu
Read the JavaScript Claude ran
const parse = r => (typeof r === "string" ? JSON.parse(r) : r);
const o = parse(await tools.mcp__symfony_code_mode__execute_tools({calls:[{name:"refund_get_order", arguments:{orderId:"R-1042"}}]}));
let p = null;
const ov = o.results?.[0]?.value;
if (ov?.policyId) p = parse(await tools.mcp__symfony_code_mode__execute_tools({calls:[{name:"refund_get_policy", arguments:{policyId: ov.policyId}}]}));
({o: JSON.stringify(o), p: JSON.stringify(p)})
search_tools · refund
{
    "arguments": {
        "query": "refund"
    },
    "result": {
        "tools": [
            {
                "name": "refund_get_order",
                "description": "Read the support order, paid amount in minor units, condition, days since delivery and applicable policy ID.",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "orderId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "orderId"
                    ],
                    "additionalProperties": false
                },
                "outputSchema": {
                    "type": "object",
                    "properties": {
                        "orderId": {
                            "type": "string"
                        },
                        "policyId": {
                            "type": "string",
                            "minLength": 1,
                            "description": "The policyId argument for refund_get_policy."
                        },
                        "currency": {
                            "type": "string"
                        },
                        "amountMinor": {
                            "type": "integer"
                        },
                        "daysSinceDelivery": {
                            "type": "integer"
                        },
                        "itemCondition": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "orderId",
                        "policyId",
                        "currency",
                        "amountMinor",
                        "daysSinceDelivery",
                        "itemCondition"
                    ],
                    "additionalProperties": false
                }
            },
            {
                "name": "refund_get_policy",
                "description": "Read the return window, accepted condition, currency and manual review threshold in minor units for a policy.",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "policyId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "policyId"
                    ],
                    "additionalProperties": false
                }
            }
        ],
        "matched": 2,
        "returned": 2,
        "limit": 8,
        "truncated": false,
        "groups": [
            {
                "name": "refund-review",
                "description": "Support team refund procedure. Open this Group for the review steps and the rules for recommending a refund."
            }
        ]
    }
}
search_tools · refund-review
{
    "arguments": {
        "group": "refund-review"
    },
    "result": {
        "group": "refund-review",
        "tools": [
            {
                "name": "refund_get_order",
                "description": "Read the support order, paid amount in minor units, condition, days since delivery and applicable policy ID.",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "orderId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "orderId"
                    ],
                    "additionalProperties": false
                },
                "outputSchema": {
                    "type": "object",
                    "properties": {
                        "orderId": {
                            "type": "string"
                        },
                        "policyId": {
                            "type": "string",
                            "minLength": 1,
                            "description": "The policyId argument for refund_get_policy."
                        },
                        "currency": {
                            "type": "string"
                        },
                        "amountMinor": {
                            "type": "integer"
                        },
                        "daysSinceDelivery": {
                            "type": "integer"
                        },
                        "itemCondition": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "orderId",
                        "policyId",
                        "currency",
                        "amountMinor",
                        "daysSinceDelivery",
                        "itemCondition"
                    ],
                    "additionalProperties": false
                }
            },
            {
                "name": "refund_get_policy",
                "description": "Read the return window, accepted condition, currency and manual review threshold in minor units for a policy.",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "policyId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "policyId"
                    ],
                    "additionalProperties": false
                }
            }
        ],
        "instructions": "Read the order, then read the policy named by that order. Compare its age and condition with the policy. If eligible, compare the amount with the manual-review threshold in the same currency. Report the recommendation and the reason. If a required read is denied, keep the facts already received, identify the missing evidence and report the review as incomplete. A review never issues a refund."
    }
}
execute_tools · refund_get_order
{
    "arguments": {
        "calls": [
            {
                "name": "refund_get_order",
                "arguments": {
                    "orderId": "R-1042"
                }
            }
        ]
    },
    "result": {
        "results": [
            {
                "name": "refund_get_order",
                "value": {
                    "orderId": "R-1042",
                    "policyId": "standard-eu",
                    "currency": "EUR",
                    "amountMinor": 7500,
                    "daysSinceDelivery": 9,
                    "itemCondition": "unopened"
                }
            }
        ]
    }
}
execute_tools · refund_get_policy
{
    "arguments": {
        "calls": [
            {
                "name": "refund_get_policy",
                "arguments": {
                    "policyId": "standard-eu"
                }
            }
        ]
    },
    "result": {
        "results": [
            {
                "name": "refund_get_policy",
                "value": {
                    "policyId": "standard-eu",
                    "currency": "EUR",
                    "returnWindowDays": 30,
                    "acceptedCondition": "unopened",
                    "manualReviewAboveMinor": 5000
                }
            }
        ]
    }
}
Read the support question and Claude’s answer
Please find and follow our team’s refund procedure for order R-1042. What should I tell the customer?
The procedure says R-1042 can get a refund, but it has to go to manual review first. The review doesn't issue refunds, so don't promise the customer the money yet.

I followed the support team's **refund-review** procedure in the `symfony_code_mode` catalogue. It has you read the order, then read the policy that order names, then check the order's age and the item's condition against that policy. If those pass, you compare the amount with the manual-review threshold.

| Check | Order R-1042 | Policy `standard-eu` | Result |
|---|---|---|---|
| Days since delivery | 9 days | Return window is 30 days | ✅ Within window |
| Item condition | Unopened | Must be unopened | ✅ Matches |
| Amount | € 75,00 | Manual review above € 50,00 (both in EUR) | ⚠️ Over the threshold |

**What to tell the customer:**

> Thank you for getting in touch about order R-1042. Your return is within our 30-day return window and the item is unopened, so it qualifies for a refund under our policy. Because of the order value, a colleague needs to approve the refund before we can process it. We'll confirm with you as soon as that's done.

**Next step for you:** send the € 75,00 refund to whoever handles manual approval. Tell them it was requested 9 days after delivery and the item is unopened.

Download the run history (JSON)

What if access changes between those two reads? In a separate replay, the client already had the order’s policy ID when the operator revoked access. Symfony denied the policy lookup before its handler ran, so the agent left the review incomplete. Inspect the recorded denial

Symfony AI agent transcript

Should we approve refund R-1042?

The team’s procedure says to read the order first, then look up the policy named in that order. Expand any of the agent’s six calls to see what it sent and what Symfony returned.

symfony_code_mode MCP over HTTP

User Use Symfony Code Mode to find and open our team’s refund review procedure. Follow it for R-1042. Should I approve the refund or send it for manual review, and why? Leave the refund unchanged.

search_tools Found refund-review and 2 tools succeeded
{
    "tool": "search_tools",
    "arguments": {
        "query": "refund review procedure"
    },
    "modelRequest": 1,
    "outcome": "succeeded",
    "handlerEvents": [],
    "result": {
        "tools": [
            {
                "name": "refund_get_policy",
                "description": "Read the return window, accepted condition, currency and manual review threshold in minor units for a policy.",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "policyId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "policyId"
                    ],
                    "additionalProperties": false
                }
            },
            {
                "name": "refund_get_order",
                "description": "Read the support order, paid amount in minor units, condition, days since delivery and applicable policy ID.",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "orderId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "orderId"
                    ],
                    "additionalProperties": false
                }
            }
        ],
        "matched": 2,
        "returned": 2,
        "limit": 8,
        "truncated": false,
        "groups": [
            {
                "name": "refund-review",
                "description": "Review an order together with its applicable refund policy."
            }
        ]
    },
    "modelToolCall": {
        "name": "symfony_code_mode_search_tools",
        "arguments": {
            "query": "refund review procedure"
        }
    },
    "resultReceivedByNextModelRequest": "4eb1407d1c7cf6ed49170745a5a03488735467e0dc37b60fc315ca99df53af19"
}
execute_tools Tried to call the group refund-review as a tool tool_denied
{
    "tool": "execute_tools",
    "arguments": {
        "calls": [
            {
                "name": "refund-review",
                "arguments": []
            }
        ]
    },
    "modelRequest": 2,
    "outcome": "tool_denied",
    "handlerEvents": [],
    "result": {
        "error": {
            "reason": "tool_denied",
            "tool": "refund-review",
            "index": 0
        },
        "completedCalls": 0
    },
    "modelToolCall": {
        "name": "symfony_code_mode_execute_tools",
        "arguments": {
            "calls": [
                {
                    "name": "refund-review",
                    "arguments": []
                }
            ]
        }
    },
    "resultReceivedByNextModelRequest": "14cc3abb1d3d2c888f65d1b0282f233c8d4255f1a4b7b4b15f30808a96d18d8b"
}
search_tools Opened refund-review · procedure and 2 tools succeeded
{
    "tool": "search_tools",
    "arguments": {
        "group": "refund-review"
    },
    "modelRequest": 3,
    "outcome": "succeeded",
    "handlerEvents": [],
    "result": {
        "group": "refund-review",
        "tools": [
            {
                "name": "refund_get_order",
                "description": "Read the support order, paid amount in minor units, condition, days since delivery and applicable policy ID.",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "orderId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "orderId"
                    ],
                    "additionalProperties": false
                }
            },
            {
                "name": "refund_get_policy",
                "description": "Read the return window, accepted condition, currency and manual review threshold in minor units for a policy.",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "policyId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "policyId"
                    ],
                    "additionalProperties": false
                }
            }
        ],
        "instructions": "Read the order, then read the policy named by that order. Compare its age and condition with the policy. If eligible, compare the amount with the manual-review threshold in the same currency. Report the recommendation and the reason. If a required read is denied, keep the facts already received, identify the missing evidence and report the review as incomplete. A review never issues a refund."
    },
    "modelToolCall": {
        "name": "symfony_code_mode_search_tools",
        "arguments": {
            "group": "refund-review"
        }
    },
    "resultReceivedByNextModelRequest": "c60c2516e8b5cb641245b63b9caf81c422055dc2d7188933a583e46c1af16679"
}
execute_tools refund_get_order · R-1042 → standard-eu succeeded
{
    "tool": "execute_tools",
    "arguments": {
        "calls": [
            {
                "name": "refund_get_order",
                "arguments": {
                    "orderId": "R-1042"
                }
            }
        ]
    },
    "modelRequest": 4,
    "outcome": "succeeded",
    "handlerEvents": [
        {
            "name": "refund_get_order",
            "phase": "requested"
        },
        {
            "name": "refund_get_order",
            "phase": "succeeded"
        }
    ],
    "result": {
        "results": [
            {
                "name": "refund_get_order",
                "value": {
                    "orderId": "R-1042",
                    "policyId": "standard-eu",
                    "currency": "EUR",
                    "amountMinor": 7500,
                    "daysSinceDelivery": 9,
                    "itemCondition": "unopened"
                }
            }
        ]
    },
    "modelToolCall": {
        "name": "symfony_code_mode_execute_tools",
        "arguments": {
            "calls": [
                {
                    "name": "refund_get_order",
                    "arguments": {
                        "orderId": "R-1042"
                    }
                }
            ]
        }
    },
    "resultReceivedByNextModelRequest": "4b28ed84b11d11b1b5313b06d352b7a3dd50aa029f8ac83547ab70d2e00c92f7"
}
execute_tools refund_get_policy · standard-eu succeeded
{
    "tool": "execute_tools",
    "arguments": {
        "calls": [
            {
                "name": "refund_get_policy",
                "arguments": {
                    "policyId": "standard-eu"
                }
            }
        ]
    },
    "modelRequest": 5,
    "outcome": "succeeded",
    "handlerEvents": [
        {
            "name": "refund_get_policy",
            "phase": "requested"
        },
        {
            "name": "refund_get_policy",
            "phase": "succeeded"
        }
    ],
    "result": {
        "results": [
            {
                "name": "refund_get_policy",
                "value": {
                    "policyId": "standard-eu",
                    "currency": "EUR",
                    "returnWindowDays": 30,
                    "acceptedCondition": "unopened",
                    "manualReviewAboveMinor": 5000
                }
            }
        ]
    },
    "modelToolCall": {
        "name": "symfony_code_mode_execute_tools",
        "arguments": {
            "calls": [
                {
                    "name": "refund_get_policy",
                    "arguments": {
                        "policyId": "standard-eu"
                    }
                }
            ]
        }
    },
    "resultReceivedByNextModelRequest": "7506821b7186a8db75e510159d351624c06e854aa52683fc806cadb65132676b"
}

Agent The order meets the policy’s return window and condition, but its amount ( €75 ) is above the manual‑review threshold of €50. Therefore you should send this refund (R‑1042) for manual review rather than approve it automatically. (No change to the refund itself is made.)

The operator revokes refund.review.

User Can you check the same policy again through Symfony Code Mode before I act? Tell me whether you could verify it this time.

execute_tools refund_get_policy · standard-eu tool_denied
{
    "tool": "execute_tools",
    "arguments": {
        "calls": [
            {
                "name": "refund_get_policy",
                "arguments": {
                    "policyId": "standard-eu"
                }
            }
        ]
    },
    "modelRequest": 7,
    "outcome": "tool_denied",
    "handlerEvents": [],
    "result": {
        "error": {
            "reason": "tool_denied",
            "tool": "refund_get_policy",
            "index": 0
        },
        "completedCalls": 0
    },
    "modelToolCall": {
        "name": "symfony_code_mode_execute_tools",
        "arguments": {
            "calls": [
                {
                    "name": "refund_get_policy",
                    "arguments": {
                        "policyId": "standard-eu"
                    }
                }
            ]
        }
    },
    "resultReceivedByNextModelRequest": "c6baa809e23d1d53df43e444b7d912f970946739c147b13ecbf880333e72610f"
}

Agent I wasn’t able to read the policy again – the request to `refund_get_policy` was denied. So I can’t verify the policy details a second time.

openai/gpt-oss-120b made these calls through Symfony AI using fixture data. Download the recorded session ↗

Reproduce the demo

Try the conversation yourself.

Start the local Symfony MCP server with PHP 8.2+ and Composer 2.5+. Leave it running.

git clone https://github.com/ronaldtebrake/symfony-hackathon.git
cd symfony-hackathon
composer install
composer demo:serve

Open examples/support as a local project in Claude Code or Codex. Trust the project and approve symfony_code_mode if prompted. Each client uses its own project configuration to fetch the temporary credential.

Open /mcp to see search_tools and execute_tools, then ask:

Please find and follow our team’s refund procedure for order R-1042. What should I tell the customer?

In the same chat, ask about a second order.

Could you check order R-1043 using the same refund procedure? What should I tell this customer?

R-1042 needs manual review because €75 exceeds the policy’s €50 threshold. For R-1043, the agent should explain that access was denied and it couldn’t complete the review.

Client setup and permission-change demo →

Design journey

From a growing catalog to a team procedure

Let PHP do the work

Every extra tool meant another definition for the agent to read. Once it found the tools, intermediate results also filled the conversation. We tried Code Mode for that second problem first: the agent wrote PHP and ran it in gVisor. A program could join several tool results and return just the findings. That helped on a data-heavy audit, but it asked every adopting team to host a sandbox. The server-side Code Mode idea ↗

Help the agent find the procedure

A searchable list solves discovery one tool at a time. Sometimes a team already knows which tools belong together. The MCP working group’s Groups draft gave us a way to describe that knowledge. A client that negotiates Groups can list them, open one and call its members. We also made the same procedure discoverable through our catalog for clients that use ordinary MCP tools. Read the named Groups proposal ↗ · See the actual MCP calls

Give the script a field it can use

Early scripts picked the policy ID out of text. We made it a named field and showed clients where to find it in the reply. Claude could then use the order’s own policy ID for its next call. Follow the policy ID between reads →

What we can contribute

Our refund demo gives each upstream discussion a concrete example.

Symfony AI

Tool search outside the agent loop

We reused the proposed search component on the server. Symfony filters the definitions for the current caller, then the ranker searches them. Our adapter needs an execution reference just to rank a definition. Could the same search API serve both agents and MCP servers?

See how we used the ranker →Tool search prototype ↗

PHP MCP SDK

Discovery depends on who’s asking

A support colleague can discover the order reader and still lack access to a particular order. Our app uses the authenticated caller to filter discovery, then checks the requested record at execution. That distinction matters when the SDK gives applications a way to filter their catalogs.

Read the request-context question ↗See the access check on a direct call →

MCP working group

What a Group adds after search

The Group description helps a client choose the refund procedure. Opening it gives the client the team’s instructions and reader definitions. Our HTTP trace shows exactly what crosses the wire at each step of the draft protocol.

Inspect the recorded exchange →Named Groups proposal ↗
Contribution notes and upstream discussions ↗

What’s next

We want another Symfony team to publish its own procedure using tools it already has. The catalog is reusable today. The Group in the film is still wired into the refund demo. Our first step is to work out how much of that wiring belongs in Symfony and the PHP MCP SDK.

Could Symfony expose the catalog?

A developer could opt in to searchable MCP tools in the bundle. We’ll ask where Symfony AI’s discovery work fits and whether the bundle should offer search and execution together. The application would still decide who may read each record.

Symfony AI discovery discussion ↗

Take a procedure to a second app

Once we know what upstream can provide, try an unrelated job: investigate a slow route. Can a developer publish the steps and point to existing profiler and log readers without copying our refund code?

Portability checklist →

Find out when Groups and Skills help

Can an agent choose between procedures that share tools? Does a linked guide help it finish the job correctly? We’ll compare answers, requests and tokens across whole tasks.

Groups and Skills discussion ↗
Follow the post-hackathon checklist →

Explore the evidence · Client tool calls · Symfony AI conversation