Skip to content

Add MCP resource support to tutorials: client, fixture server, and integration - #255

Merged
MisterVVP merged 16 commits into
mainfrom
dev-extend-production-tutorials-with-mcp-integration
Oct 1, 2026
Merged

MisterVVP merged 16 commits into
mainfrom
dev-extend-production-tutorials-with-mcp-integration

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Motivation

  • Enable tutorial specialists to fetch textual resources via MCP URIs so examples demonstrate MCP-based resource resolution rather than local files.
  • Provide a deterministic, local MCP fixture server for CI and local testing to avoid external credentials and make resource behavior reproducible.
  • Wire MCP support through the build, Docker Compose, and smoke-test scripts so tutorials remain runnable end-to-end with resource-mode flows.

Description

  • Add a small C++ MCP client (examples/tutorials/common/mcp_client.{h,cpp}) that implements JSON-based initialize, notifications/initialized, and resources/read interactions with session header handling and protocol validation.
  • Extend the two tutorials to accept resource URIs and resolve them via MCP by adding flags and request variants, updating tutorial.* logic, and registering the MCP client in the agent Executor constructors.
  • Add an official-SDK-based deterministic MCP fixture server (examples/tutorials/mcp_server/server.py), a lightweight Dockerfile and requirements.txt, and wire it into docker-compose for both tutorials.
  • Update CMakeLists to compile and link mcp_client.cpp into tutorial libraries and add include directories; update README usage and run scripts to describe and start the MCP server and to use --*-resource flags.
  • Update integration/smoke scripts (scripts/run_tutorials.sh, scripts/run_tutorial_docker_smoke.sh) to start the MCP server, exercise resource URIs, and assert expected outputs and error handling (missing/unavailable resources).

@MisterVVP MisterVVP added the codex Automatic label added by codex agent. Should not be used label Sep 24, 2026 — with ChatGPT Codex Connector
@MisterVVP MisterVVP self-assigned this Sep 24, 2026
@MisterVVP MisterVVP added documentation Improvements or additions to documentation enhancement New feature or request AI agent AI agent contribution and removed codex Automatic label added by codex agent. Should not be used labels Sep 24, 2026
@MisterVVP
MisterVVP force-pushed the dev-extend-production-tutorials-with-mcp-integration branch from 5125d2a to bc6e697 Compare September 24, 2026 14:53
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@MisterVVP
MisterVVP marked this pull request as ready for review September 24, 2026 15:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc6e697f18

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/run_tutorials.sh Resolved
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f3e69eabf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/unit/mcp_client_test.cpp Resolved
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be75185ea8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR again

@MisterVVP MisterVVP linked an issue Sep 25, 2026 that may be closed by this pull request
14 tasks

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2117933dd4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR again, do not send bugs 1 by 1, batch all of them (if any) inside a single review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: a90325bbbc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP

Copy link
Copy Markdown
Owner Author

Under human review & testing now

@MisterVVP

MisterVVP commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner Author

Let's do this differently without custom MCP server implementation

@MisterVVP

Copy link
Copy Markdown
Owner Author

Continues at #256

…256)

- Replace the tutorial-only custom MCP fixture with a realistic
third-party MCP/OAuth setup.
- Keep the production tutorials deterministic and CI-friendly while
showing a clearer separation between A2A agent communication and MCP
resource access.
- Make the local and Docker Compose tutorial workflows easy to discover
and run.

- Refactored Customer Support Copilot to use ContextForge `v1.0.10` for
MCP resources and Keycloak `26.7.4` for OAuth.
- Added a short-lived `client_credentials` flow for the `mcp-agent`
client, verified HTTPS with an ephemeral local CA, and a least-privilege
ContextForge service principal with `servers.use` and `resources.read`.
- Added ContextForge bootstrap automation that configures Keycloak
trust, registers the deterministic ticket resource, creates the virtual
MCP server, requests the access token, and writes the runtime MCP
environment for the specialist.
- Simplified the shared C++ MCP client to a stateless MCP `2025-11-25`
`resources/read` request with bearer authentication, bounded timeouts,
response validation, and no token logging.
- Added Docker Compose coverage for the authenticated Customer Support
flow, including an unauthenticated rejection check and an authenticated
MCP preflight before the A2A agents start.
- Restored Job Application Assistant to its file-based A2A-only flow and
removed the old custom MCP server fixture.
- Kept host-native tutorial smoke deterministic through
`scripts/run_tutorials.sh`.
- Refactored the root and tutorial READMEs so the supported local and
Docker Compose entry points are short, explicit, and consistent.
- Updated MCP client unit tests for the stateless request/response
behavior and error handling.

---------

Co-authored-by: Vladimir Pavlov <[email protected]>
@MisterVVP
MisterVVP force-pushed the dev-extend-production-tutorials-with-mcp-integration branch from fd3d5e5 to 20570a6 Compare September 29, 2026 14:04
@MisterVVP MisterVVP added the human Human contribution label Sep 29, 2026
@MisterVVP

Copy link
Copy Markdown
Owner Author

Ok, no more custom MCP servers. Dockerized setup has already been verified on windows, however this PR requires another QA round on Linux and final doc. review.

Extra neat features (like some UI for tutorials) should be out of scope. This PR demonstrates how tutorial app works with OAuth-protected MCP resource through Keycloak and ContextForge.

@MisterVVP

Copy link
Copy Markdown
Owner Author

Tested on Linux

@MisterVVP

MisterVVP commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner Author

@codex pls review this PR, remember that tutorials are created for demo purposes, not for real production usage. The goal of tutorials is to demonstrate how production applications can be built with this SDK.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20570a682e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

MisterVVP and others added 3 commits September 30, 2026 17:38
### Motivation
- Prevent CRLF/header injection via user-supplied resource URIs that are
copied into the `Mcp-Name` header and accepted by libcurl.\
- Enforce URI validation at both protobuf-boundary helpers and the MCP
client boundary to fail-fast and avoid emitting attacker-controlled
outbound headers.\

### Description
- Add `ValidateResourceUri(std::string_view, std::string_view)` in
`examples/tutorials/common/resource_validation.h` which rejects empty
values and any ASCII control characters (chars < 0x20 and DEL 0x7f).\
- Update `ValidateResourceUriField` to reuse `ValidateResourceUri` for
protobuf string values.\
- Apply validation in `Client::ReadResource` (in
`examples/tutorials/common/mcp_client.cpp`) before constructing the
outbound request and headers, returning the validation error if the URI
is invalid.\
- Add unit tests in `tests/unit/mcp_client_test.cpp` to cover
CRLF/header-injection style input and other control characters, and
update tests to set protobuf string values with `std::string` where
needed.\
@MisterVVP MisterVVP added this to the v0.6.0 milestone Oct 1, 2026
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR again. Bear in mind that this is tutorials, not core SDK, so no nitpicking!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d05c0b0ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR again, no nitpicks

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2fdf2766ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MisterVVP
MisterVVP merged commit ddd9fcb into main Oct 1, 2026
21 checks passed
@MisterVVP
MisterVVP deleted the dev-extend-production-tutorials-with-mcp-integration branch October 1, 2026 17:11
@MisterVVP MisterVVP mentioned this pull request Oct 8, 2026
4 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution documentation Improvements or additions to documentation enhancement New feature or request human Human contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: add MCP-backed data sources to production tutorials

1 participant