Video summary
In this session, Michael, a principal developer advocate at GitLab, demonstrates how to leverage OpenAI Codex to resolve complex software bugs by enriching its context with specific project data using the GitLab MCP server. The primary use case involves fixing a metric filtering issue in a Rust-based backend service for the Tanuki ID platform, where the system was incorrectly returning all metrics instead of filtering by sensor or metric as intended. By configuring the Codex CLI to connect to a self-managed or dedicated GitLab instance and enabling the necessary MCP client feature flags, developers can grant Codex access to specific repositories and issues. This setup allows the AI to read detailed issue descriptions, including functional requirements, non-functional constraints, and suggested implementation plans, effectively transforming it into an informed pair programmer that understands the full scope of the problem before writing code.
Once connected, Codex autonomously fetches the complete context for a specific issue, such as Issue 32, and begins generating a solution that adheres to the project's existing patterns and documentation standards. The AI not only writes the corrected Rust code but also updates related files like README.md and agents.md, runs necessary formatting checks with tools like clippy, and compiles the source code to ensure there are no errors. Furthermore, Codex handles the Git workflow seamlessly by automatically creating a new branch, committing the changes, and initiating a merge request without requiring manual intervention for each step. This automation significantly reduces the cognitive load on developers, allowing them to focus on higher-level architecture while the AI manages the tedious tasks of code generation, testing, and version control operations.
The integration extends beyond mere code generation by fully leveraging GitLab's native CI/CD pipelines and security protocols. Upon creating the merge request via MCP tool calls, Codex triggers automated builds, unit tests, and security scanning jobs to verify the integrity of the changes. The system also engages GitLab Duo for a comprehensive code review, checking against style guides and ensuring clean implementation with proper documentation updates. A key efficiency gain highlighted is that Codex automatically references the issue number in the merge request description, which ensures that once the request is merged, the original issue is closed automatically. This end-to-end workflow guarantees that every change undergoes rigorous validation through code owners' approvals and security gates before being applied to the main branch.
Ultimately, this demonstration showcases a powerful synergy between generative AI and established DevOps practices, turning Codex into an efficient agent capable of delivering production-ready fixes with minimal human oversight. After merging the request, the presenter manually restarts the WebSocket handler to apply the fix in the live environment, confirming that the metric filtering now works correctly by streaming only the intended temperature Celsius data. This successful resolution validates the approach of using GitLab MCP servers to provide Codex with deep SDLC context, resulting in faster development cycles, reduced bug rates, and a streamlined process for integrating AI-generated code into existing enterprise workflows without compromising on quality or security standards.
Read the full video transcript
Hello everyone. My name is Michael. I'm
a principal developer advocate here at
GitLab and in today's session I want to
dive into Codex
and how we can enrich the context for
generative AI
with the GitLab MCP server and the
GitLab Duo agent platform. Um for this
purpose we are looking into uh the
Tanuki ID platform project again um
which got a new backend service here. So
we have um a metric store written in
Rust and this is working properly
um and in the previous recording we
tried to fix a problem with metric
filtering for the web socket stream. So
the problem is
um you
want to filter by sensor and by metric
um but it doesn't work filtering by
metric. So ev- any metric is being
returned.
Um to quickly show you that it's still
not working.
We can see
uh the metrics are sent and we also get
a different metric. So
um this is the problem we need to
address. Fortunately, um we do have an
issue for that. So this specific issue,
issue number 32 um describes the problem
that we need to solve with additional
functional requirements, query parameter
behavior, non-functional requirements,
implementation notes and even like a
suggested implementation plan. Um and we
can use that uh for our advantage um
or like me as a developer now um I want
to have access to that GitLab issue and
one way to do that is by using the
GitLab MCP server in Codex.
Um
and here are the docs um which we need
to do or which we need to follow.
It works again skilledup.com so
skilledup.com SAS
dedicated or a self-managed skilledup
instance
and the only thing we need to do is
actually to use the codex CLI
add the configuration for the MCP server
and then also add a feature flag
which is the RMCP client which needs to
be set to true. This is the setup that I
tested verified working. Maybe the
feature flag is not needed anymore but
better be safe than sorry. The next step
is to actually do that. So let's switch
back to our terminal but not this one
but the other one which I prepared over
here and we run the command to add the
gitlab.com MCP server here.
This automatically opens
um
an OAuth application approval for codex.
So we want to approve that against the
MCP server
and codex is saying we are successfully
logged in.
Um let's verify
the
um
the configuration which is this one. So
I press control R to search my my
history in the terminal here
and um you can see the feature flag is
set. The project that we're using is
also trusted and um the MCP server has
been added here as well. So this looks
great.
Now we can start using codex by opening
up in the terminal here.
We want to get help with implementing
the issue. So let's
go back to the issue. As I said 32 is
the number. So um let's just instruct
codex with please help me
fix
issue 32.
And expectation is that Codex
figures out which MCP servers are
available, which tool calls it can use
in order to fetch the context and the
content of issue 32.
Um so now it does
um
check the remote to figure out the
project path and get also the
instructions from agents.md
and related.
And
yeah, it immediately calls the MCP tool
get issue from the GitLab MCP server,
gets the full context um including the
milestone, the labels, the issue
discussion related
uh implementation
um
and starts working.
Uh let's scroll up over here. Um we do
see the optional metric. Um
the filters are being defined. Here is
the the um
the WS filters match functionality
um either matching against the sensor or
the metric uh query parameter.
And
um
implements that. So it's now
calling it's a callback to the
uh
to that function um binding in the the
sensor and the metric parameters.
It's nice. Um
another rust
uh not not a rust export um but I can
read and compile it in my head sort of.
Uh here are the tests.
Uh this is also it looks also good and
it continues with the changes to update
the readme.md file, the agents.md
and um
now runs the required rust formatting
test and clippy commands uh which are
defined in the agent zone D file,
and uh
is quite fast in everything.
Cargo build has passed, so the source
code source code has compiled with the
changes.
And now it's creating a Git branch and
commits the changes for issue 32, so we
will have the immediate reference.
And now it wants to create a Git uh a
Git branch. This is great, so I don't
need to ask for that. It automatically
wants to create a merge request.
Saves me one thinking step,
and um I can also set the merge request
to draft if I want to continue working
on that
um later, but essentially we are saving
a little bit of time
uh to persist the changes and maybe hand
it over to a teammate um
while working on other things.
We can also use it as a way to verify
the changes against uh code review style
guide and and CI/CD already. So, yes, we
want to commit that.
And now it uses the GitLab MC server to
create a merge request, um
which we can allow for this session,
allow once, or always allow. Let's just
pick the first section here.
Um so, this uses a directly a tool call
um on the MC server.
Okay, let's open the merge request. So,
I'm pressing command to click on that.
And we can see uh the CI/CD pipelines
have been kicked off over here.
So, the build is running for the Rust
back end because only changes in the
Rust back end have been made, and later
on we will also see that uh the security
scanning um
jobs are running after the build is
complete, and also the um
test will will run.
And you can see
um the pipelines have passed. Um so the
build is okay.
Um
the test for the rest um
back end are okay.
And
um
we can scroll down here and see that
GitLab Pro has finished the code review.
So it's also um fine according to the um
review instructions that were provided.
Clean implementation, comprehensive test
coverage, proper documentation updates
in readme.md and agents.md with clear
examples, follows existing code patterns
and also efficient filtering logic and
semantics
uh when both sensor and metrics filters
are provided. So this looks good from
the review perspective.
Um one other thing I want to highlight
here because Codex had the full issue
context through the GitLab MCP server,
it knows about issue number 32 and
immediately adds closes 32 into the
issue into the merge request
description. So when we approve and
merge this merge request, it will
automatically close the issue. This is
quite an efficiency improvement. You can
also see over here it's closing the
issue. And um when I click merge, it
will be added over here.
Um
The remaining bit for this merge request
is now um that we also want to change um
uh not change, test the changes locally.
Uh while we have been waiting that
security scanning didn't detect
anything. So this is good to go. Um and
the final bit is to change back to the
terminal
and uh change to our
um
tests over here. Let's stop the demon
and restarted again.
Stop the web socket handler and restart
it.
So, we can see
that the filtering should only show the
temperature Celsius here, send in the
metrics again, and bingo, everything
works. Only the temperature Celsius
metric is
streamed to the web socket, and if we
would have like a web dashboard, we get
the correct metrics and not
a buggy version that we had before. So,
the fix is working and going back into
the merge request here,
we can then see if we open up the issue.
Going back here,
the reference we
with the implementation,
and
we're good to go. So, to summarize, we
used CodeX with the GitLab MCP server to
enrich the to enrich the context with
the full issue description and all the
requirements.
Everything worked out. The merge request
was created using MCP tool calls.
Then, it kicked off CI/CD security
scanning automatically. All the proper
gateways from GitLab also apply with
required approvals from code owners,
security scanning,
and also GitLab to agent platform code
review.
So, yeah, this is a good example for
efficiency
with CodeX together with GitLab.
Thanks for watching. I hope you learned
something new today, and see you in the
next session.