<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jarno Ralli on Medium]]></title>
        <description><![CDATA[Stories by Jarno Ralli on Medium]]></description>
        <link>https://medium.com/@jarno-ralli?source=rss-65374e8aa42d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XOFHAJpBwfH_m3Z601ARUA.png</url>
            <title>Stories by Jarno Ralli on Medium</title>
            <link>https://medium.com/@jarno-ralli?source=rss-65374e8aa42d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:43:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jarno-ralli/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a GStreamer MCP Server: Context Optimization in Agentic Development]]></title>
            <link>https://medium.com/@jarno-ralli/building-a-gstreamer-mcp-server-context-optimization-in-agentic-development-5f765d753bd3?source=rss-65374e8aa42d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f765d753bd3</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[gstreamer]]></category>
            <category><![CDATA[model-context-protocol]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Jarno Ralli]]></dc:creator>
            <pubDate>Tue, 23 Jun 2026 15:51:51 GMT</pubDate>
            <atom:updated>2026-07-05T12:46:28.722Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article I will discuss how the context given to an agent can be optimized when developing complex image processing GStreamer pipelines with Model Context Protocol (MCP). I will explain what challenges engineering managers typically face when trying to rapidly grow the size of the engineering team that use complex tooling and how this can be alleviated with the existing agentic development tools and approaches, such as Model Context Protocols (MCPs).</p><p>The example I have chosen here is related to building image processing pipelines using GStreamer framework, but the same principles apply to other use cases as well.</p><h4>Expanding Engineering Teams and Complex Tooling</h4><p>Expanding engineering teams that implement complex video analytics pipelines based on bleeding edge computer vision technology is challenging due to a number of reasons. In the following I highlight some of the problems</p><ul><li><strong>Quickly evolving field</strong>. The developers need to keep track of what is happening in the field so that they can create competitive solutions. In a field that is developing at an ever faster pace, this task itself is challenging.</li><li><strong>Solution complexity</strong>. Implementing efficient production quality video analytics pipelines is challenging since the developers need to have expertise in several key areas. For example, they need to understand subtleties of different inference frameworks and how the chosen hardware influences the inference times and what can be executed in parallel and how. Poor efficiency typically translates into increased hardware costs for the end client, making the product less competitive in the markets.</li><li><strong>On-boarding tax</strong>. New engineers joining the team need to learn the code base and the tools and frameworks being used by the engineering team. Counterintuitively, hiring more team members typically causes a temporary dip in output, especially if the tooling has a steep learning curve, as seasoned engineers must dedicate time to on-boarding.</li></ul><p>Regarding the solution complexity and the on-boarding tax, this is where agentic development tools can help by allowing the team to overcome the learning curve faster, shortening the timeline to increased team output.</p><p>However, introducing agentic tools for the engineering team is not a silver bullet that fixes the problems automatically. If the tools are not fine tuned properly so that the underlying LLMs understand the code base and the context, we are only shifting the problem elsewhere. With poorly tweaked agentic tools the engineers get stuck in endless iteration loops which might actually decrease output from the team.</p><h4>Model Context Protocol (MCP) and Agents</h4><p>In my LinkedIn article called <a href="https://www.linkedin.com/pulse/do-large-language-models-dream-jarno-ralli-phd-pve6f/">Do Large Language Models Dream</a> I explained that every LLM response is a probabilistic reconstruction of compressed knowledge and how context injection via RAG, MCP or similar technologies can steer the LLM in the desired direction.</p><p>The Model Context Protocol (MCP) is an open standard and open-source framework introduced by Anthropic that allows LLMs to access external systems via tools. These tools can provide, for example, access to databases, documentation or other sources of information. Most harnesses support MCPs and integrating these into the agentic flow is typically as simple as adding the MCP in the agent’s configuration file.</p><p>Model Context Protocol is not the only technology that allows agents to use tools to extend what they can do. For example, LangChain’s <a href="https://docs.langchain.com/oss/python/langchain/tools">Tools</a> provide similar functionality, allowing agents to execute code, access databases, and so on. The main difference between LangChain’s Tools and MCP is that in the case of LangChain the tools are more application oriented whereas in the case of MCP, the idea is that the tools are exposed to all the agents that would benefit from using these. Even though there is some overlap between the functionalities offered by LangChain and MCP, I see these more supplementing rather than competing with each other.</p><p>However, the topic of this article is not the pros and cons of LangChain and MCP, but a concrete use case where an MCP server exposes some of the internals of the GStreamer framework to server as context for LLMs.</p><h4>GStreamer and Video Analytics</h4><p>Released in 2001 and written in C, GStreamer is arguably the largest media framework in existence. Its modular architecture relies on chaining together processing elements to form complex multimedia pipelines. This modularity makes it a perfect candidate for building efficient, high performance video analytics workflows. For example, NVIDIA’s DeepStream and Intel’s Deep Learning Streamer are built on top of GStreamer. However, all the functionality comes at a steep cost. The sheer scale of the framework, combined with paradigms like dynamic GObject introspection, makes the learning curve very steep for new developers not familiar with the framework.</p><p>Coding agents typically handle relatively well basic GStreamer related development tasks, but depending on the used programming language (GStreamer has bindings for Go, Python, Rust, Vala, C++, Perl, and so on), sometimes the agent cannot find the correct information with the tools it has at its disposal. For example, due to the modular structure, some of the elements might not be available in the local GStreamer installation. If the approach taken by the agent does not work, due to any number of reasons, the agent might end up downloading and analyzing GStreamer’s source code, and iteratively trying different approaches. There is nothing wrong with this approach per se, it’s pretty much the same approach taken by a human developer. However, this can lead to the following problems</p><ul><li><strong>Context window</strong>. The context window starts filling up which after certain point can have a negative impact on the agents reasoning skills.</li><li><strong>Token waste</strong>. This can waste a lot of tokens as the agent needs to test out different combinations iteratively.</li></ul><p>This is where a GStreamer Model Context Protocol (MCP) server comes handy by exposing the information that the agent requires as context.</p><h4>GStreamer MCP Server for Agentic Development</h4><p>The idea of the GStreamer MCP server is to provide information of different elements available, language bindings, types of arguments, etc. so that the agent has all the information that it needs for the task at a hand. The tools exposed by the server provide the information that the agent needs, in Markdown format, without flooding the context window. Architecturally the GStreamer MCP server has been implemented so that it contains the following components</p><ul><li><strong>Context server</strong>. The context server extracts information from the local GStreamer installation.</li><li><strong>MCP server</strong>. The MCP server exposes the tools to the harness.</li></ul><p>The reason for choosing this architecture is that we want to be able to use the MCP server in a configuration where the server runs in the host together with the harness and the context server runs inside a Docker container where the GStreamer is installed. This architecture gives us the possibility of testing different GStreamer versions effortlessly. Figure 1 shows the system architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*QkI4MK8ekgieYxD9nbQgLQ.png" /><figcaption>Figure 1. GStreamer MCP architecture.</figcaption></figure><p>As can be seen from Figure 1, OpenCode (the harness) communicates with the GStreamer MCP server using the MCP protocol. The <strong>MCP server</strong> (<em>gstreamer_mcp.py</em>) communicates with the <strong>context server</strong> (<em>gstreamer_mcp_server.py</em>) using a REST-interface.</p><p>To simplify testing and deployment, the system can be launched using the following Docker Compose file:</p><pre>services:<br>  gstreamer-docs-cpu:<br>    build:<br>      context: .<br>      dockerfile: Dockerfile-gstreamer-1.28<br>    image: gstreamer-1.28-mcp<br>    container_name: gstreamer-mcp-cpu<br>    working_dir: /workspace<br>    ports:<br>      - &quot;127.0.0.1:8000:8000&quot;<br>    volumes:<br>      - ../:/workspace<br>    environment:<br>      - PYTHONPATH=/usr/local/lib/python3/dist-packages:/usr/local/lib/python3.12/site-packages<br>      - GI_TYPELIB_PATH=/usr/local/lib/x86_64-linux-gnu/girepository-1.0<br>      - LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu<br>      - GST_PLUGIN_PATH=/usr/local/lib/x86_64-linux-gnu/gstreamer-1.0<br>    # Override default CMD to run the FastAPI app directly with uvicorn<br>    command: uvicorn docker.gstreamer_mcp_server:app --host 0.0.0.0 --port 8000<br><br>  gstreamer-docs-cuda:<br>    build:<br>      context: .<br>      dockerfile: Dockerfile-gstreamer-1.28-cuda<br>    image: gstreamer-1.28-cuda-mcp<br>    container_name: gstreamer-mcp-cuda<br>    working_dir: /workspace<br>    ports:<br>      - &quot;127.0.0.1:8000:8000&quot;<br>    volumes:<br>      - ../:/workspace<br>    environment:<br>      - PYTHONPATH=/usr/local/lib/python3/dist-packages:/usr/local/lib/python3.12/site-packages<br>      - GI_TYPELIB_PATH=/usr/local/lib/x86_64-linux-gnu/girepository-1.0<br>      - LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu<br>      - GST_PLUGIN_PATH=/usr/local/lib/x86_64-linux-gnu/gstreamer-1.0<br>    # Enable NVIDIA GPUS<br>    deploy:<br>      resources:<br>        reservations:<br>          devices:<br>            - driver: nvidia<br>              count: all<br>              capabilities: [gpu, compute, video, utility, graphics]<br>    # Override default CMD to run the FastAPI app directly with uvicorn<br>    command: uvicorn docker.gstreamer_mcp_server:app --host 0.0.0.0 --port 8000</pre><h4>Context Server</h4><p>The context server runs inside the Docker container, providing the information requested by the harness via the Model Context Protocol (MCP). Implemented using the FastAPI Python framework, the context server also features a dashboard that allows developers to interact with the server directly. Figure 2 shows all the different <em>.gir</em> files that have been discovered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*omr-fFt5GI6GmFrMaFlBYA.png" /><figcaption>Figure 2. GObject introspection registry.</figcaption></figure><p>All the different discovered GStreamer elements are shown in the dashboard as well, shown in Figure 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8GDMD6wOC_qhx1p4MyvPQA.png" /><figcaption>Figure 3. Registered GStreamer elements.</figcaption></figure><h4>Tools Exposed by the MCP Server</h4><p>So, what are the actual tools that are exposed by the GStreamer MCP server? Following is a list of things that are exposed in the current implementation</p><ul><li><strong>Querying Introspection Bindings using PyGObject</strong><br>- Tool name: <em>get_python_gst_docs</em><br>- The agent can query Python bindings regarding function arguments, docstrings, argument types, and class hierarchies.<br>- The context server uses Python reflection (querying from a runtime object)and PyGObject introspection.</li><li><strong>Querying C Signatures</strong><br>- Tool name: <em>get_c_gst_docs</em><br>- The agent can query C function signatures, structs, pointers, and virtual methods.<br>- This is based on parsing the .gir (XML) files.</li><li><strong>Discovering GObject Namespaces &amp; Classes</strong><br>- Tool name: <em>list_gst_classes</em><br>- The agent can discover which GObject namespaces (e.g., GstVideo, GstAudio, GLib) are installed and list all queryable GObject class paths available inside the container.<br>- This parses .gir XML files on-demand with lazy memory caching.</li><li><strong>Searching Registered GStreamer Elements</strong><br>- Tool name: <em>list_gst_elements</em><br>- The agent can query which elements are actually available in the live containerized GStreamer registry.<br>- Supports searching by keyword and filtering by semantic class/classification (e.g., Decoder, Source, Sink).</li><li><strong>Inspecting GStreamer Element Details</strong><br>- Tool name: <em>get_gst_element_details</em><br>- The agent can query detailed, structured schemas of a given element (typed properties, defaults, readable/writable flags, pad templates, and mime caps).<br>- To save context space, the raw gst-inspect-1.0 CLI specs are omitted by default and can be optionally loaded on-demand.</li><li><strong>Dry-running a Pipeline</strong><br>- Tool name: <em>validate_gst_pipeline</em><br>- The agent can easily test if a given pipeline string manages to successfully negotiate caps, transition states, and link pads.<br>- Captures and reports precise caps-negotiation warnings, state errors, and link failures in an automated loop.</li></ul><p>The aim is to give the agent the required tools for discovering what elements are available, what do these do and most importantly, how can these be connected to create a pipeline. Output from the context server is in JSON that is parsed by the MCP server into Markdown or plain-text strings. The agent does not have to double guess what elements are available in GStreamer installed in the Docker container since this can directly be queried. Also, function signatures for C and Python are available (easy to expand for other languages), along with type information, further giving more context to the agent.</p><p>Following is an example for the tool <strong>get_gst_element_details</strong> outputs for element called <strong>jpeg2000parse:</strong></p><pre># Element: jpeg2000parse<br>**Classification:** Codec/Parser/Video/Image<br>**Description:** Parses JPEG 2000 files<br>**Author:** Aaron Boxer &lt;boxerab@gmail.com&gt;<br><br>## Pad Templates<br>### SINK Pad<br>```text<br>image/jp2;<br>image/x-jpc;<br>image/x-j2c;<br>image/x-jpc-striped<br>```<br><br>### SRC Pad<br>```text<br>image/x-jpc, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], sampling=(string){ RGB, BGR, RGBA, BGRA, YCbCr-4:4:4, YCbCr-4:2:2, YCbCr-4:2:0, YCbCr-4:1:1, YCbCr-4:1:0, GRAYSCALE, YCbCrA-4:4:4:4 }, colorspace=(string){ sRGB, sYUV, GRAY }, profile=(int)[ 0, 49151 ], parsed=(boolean)true;<br>image/x-j2c, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], sampling=(string){ RGB, BGR, RGBA, BGRA, YCbCr-4:4:4, YCbCr-4:2:2, YCbCr-4:2:0, YCbCr-4:1:1, YCbCr-4:1:0, GRAYSCALE, YCbCrA-4:4:4:4 }, colorspace=(string){ sRGB, sYUV, GRAY }, profile=(int)[ 0, 49151 ], parsed=(boolean)true;<br>image/x-jpc-striped, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], sampling=(string){ RGB, BGR, RGBA, BGRA, YCbCr-4:4:4, YCbCr-4:2:2, YCbCr-4:2:0, YCbCr-4:1:1, YCbCr-4:1:0, GRAYSCALE, YCbCrA-4:4:4:4 }, colorspace=(string){ sRGB, sYUV, GRAY }, profile=(int)[ 0, 49151 ], num-stripes=(int)[ 2, 2147483647 ], parsed=(boolean)true<br>```<br><br>## Properties Schema<br>| Property Name | Type | Default | Access | Description |<br>| :--- | :--- | :--- | :--- | :--- |<br>| `name` | `gchararray` | `jpeg2000parse0` | R/W | Name |<br>| `parent` | `GstObject` | `None` | R/W | Parent |<br>| `disable-passthrough` | `gboolean` | `False` | R/W | Disable passthrough |<br>| `disable-clip` | `gboolean` | `True` | R/W | Disable Clip |</pre><h4>Empirical Testing</h4><p>Empirical testing showed that using the GStreamer MCP server in OpenCode with Gemini Flash 3.5 as the LLM helped the agent to “understand” how to implement the required pipelines and individual processing elements without as many iterations as what would have been required without it. The GStreamer MCP server that was implemented is not a fully fledged design yet as it doesn’t expose all internals of GStreamer, however new functionality can easily be added to further improve its capabilities.</p><h4>Conclusions</h4><p>Providing correct context for the agent minimized the number of required iterations so that the agent could implement more complex GStreamer pipelines and elements. This approach is not limited to agents developing code using the GStreamer framework, but extends to other areas as well where the agent needs to provide precise answers. Using agentic tools can help engineering managers build their teams faster, but only if the tools are given the proper context.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f765d753bd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>