--- AI TRACKER METADATA ---
Update Summary: Use a real MCP Client PHP library
Check-in Date: MM/DD/YYYY (US format) [When we should see progress/get an update]
Due Date: MM/DD/YYYY (US format) [When the issue should be fully completed]
Blocked by: [#XXXXXX] (New issues on new lines)
Additional Collaborators: @username1, @username2
AI Tracker found here: https://www.drupalstarforge.ai/
--- END METADATA ---

Problem/Motivation

Right now, to implement the MCP client-side, we write it ourselves. Adopting a PHP library to use the MCP will save us a lot of maintenance.

Client Libraries

Server Libraries

The server libraries may involve a client but I don't think that will be the case long term.
Maybe we build the symfony MCP client?

Issue fork mcp_client-3534518

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

robloach created an issue. See original summary.

robloach’s picture

Status: Active » Needs work

Had a first attempt at this over at https://git.drupalcode.org/project/mcp_client/-/merge_requests/1 . It seems the Drupal request out to the MCP servers is broken. Still need to investigate.

The PHP library also supports SSE, STDIO, or HTTP requests, so we should likely add that as options in the MCP entity type.

marcus_johansson’s picture

@robloach - I think https://github.com/symfony/mcp-sdk will be more interesting going forward, if they keep up the work.

yautja_cetanu’s picture

Priority: Normal » Critical
yautja_cetanu’s picture

Issue summary: View changes
marcus_johansson’s picture

Since it will take some time to get a first stable tagged verison from Symfony AI, I think we should implement it using SwisNL for now so we have an MCP Client that you can setup without a npm middle layer.

marcus_johansson’s picture

Issue summary: View changes
Issue tags: +priority
robertoperuzzo’s picture

Assigned: Unassigned » robertoperuzzo

robertoperuzzo’s picture

StatusFileSize
new5.18 MB

I made the first integration with the SwisNL library, and the STDIO connection seems to work properly (see the screencast)

robertoperuzzo’s picture

Assigned: robertoperuzzo » Unassigned
Status: Needs work » Needs review
marcus_johansson’s picture

Status: Needs review » Needs work

I could get it to setup via STDIO as well. SSE does not work, I did not try streamable http. Also the execution doesn't work yet, just the tool listing.

Also there are a lot of .ddev, .copilot that shouldn't be in there. But its a good start!

robertoperuzzo’s picture

Thank you very much, Marcus, for your feedback.

  • The STDIO execution seems to work. I tested the slack_post_message tool post message
  • The .ddev folder is used by the ddev-drupal-contrib addon to simplify contributions.
  • The .copilot one is a temporary folder where I store documentation, context, and prompts to help me with coding. I'll remove it when the job is complete.
robertoperuzzo’s picture

Assigned: Unassigned » robertoperuzzo
robertoperuzzo’s picture

StatusFileSize
new416.26 KB
robertoperuzzo’s picture

Assigned: robertoperuzzo » Unassigned
Status: Needs work » Needs review

Changes made:

  • fixes the STDIO transporter response, so it should work properly
  • implemented a custom streamable HTTP transporter because of two SwisNL missing:
    1. The StreamableHttpTransporter::initializeConnection() registers shutdown handlers that stop the ReactPHP event loop immediately after initialisation completes. This causes "Connection aborted early" errors in Drupal.
    2. The StreamableHttpTransporter class extends SseTransporter, which does not handle the authentication header (look at getDefaultHeaders()

marcus_johansson’s picture

Status: Needs review » Fixed

Thank you so much Roberto!!! We know have something that can have a alpha release as soon as we have Tool integration also.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.