<?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 Siddharth Sarathe on Medium]]></title>
        <description><![CDATA[Stories by Siddharth Sarathe on Medium]]></description>
        <link>https://medium.com/@sarathesid?source=rss-481d7da9cbe2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hq-y1PnQQyohbu9siTNOTQ.jpeg</url>
            <title>Stories by Siddharth Sarathe on Medium</title>
            <link>https://medium.com/@sarathesid?source=rss-481d7da9cbe2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:03:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sarathesid/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[Spring AI MCP using Streamable-HTTP]]></title>
            <link>https://medium.com/@sarathesid/spring-ai-mcp-using-streamable-http-f3446d2c2079?source=rss-481d7da9cbe2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3446d2c2079</guid>
            <category><![CDATA[mcp-client]]></category>
            <category><![CDATA[streamable-http]]></category>
            <category><![CDATA[spring-ai]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Siddharth Sarathe]]></dc:creator>
            <pubDate>Sun, 28 Sep 2025 03:55:09 GMT</pubDate>
            <atom:updated>2025-09-28T03:55:09.879Z</atom:updated>
            <content:encoded><![CDATA[<p>The <strong>Streamable HTTP transport</strong> enables MCP servers to run as independent processes that support multiple client connections via HTTP POST and GET requests. It also provides optional <strong>Server-Sent Events (SSE)</strong> for streaming multiple server messages, serving as a replacement for the older SSE transport.</p><p>Introduced in <strong>spec version 2025–03–26</strong>, this transport is particularly well-suited for applications that need to push dynamic updates about tools, resources, or prompts to connected clients.</p><h3><strong>MCP Server</strong></h3><p><strong>pom.xml</strong></p><pre>&lt;properties&gt;<br>        &lt;java.version&gt;25&lt;/java.version&gt;<br>        &lt;spring-ai.version&gt;1.1.0-M2&lt;/spring-ai.version&gt;<br>&lt;/properties&gt;<br><br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-ai-starter-mcp-server-webmvc&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br><br>&lt;dependencyManagement&gt;<br>        &lt;dependencies&gt;<br>            &lt;dependency&gt;<br>                &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>                &lt;artifactId&gt;spring-ai-bom&lt;/artifactId&gt;<br>                &lt;version&gt;${spring-ai.version}&lt;/version&gt;<br>                &lt;type&gt;pom&lt;/type&gt;<br>                &lt;scope&gt;import&lt;/scope&gt;<br>            &lt;/dependency&gt;<br>        &lt;/dependencies&gt;<br>    &lt;/dependencyManagement&gt;</pre><ul><li><strong>Create tool: </strong>Here, i am creating a simple addition tool</li></ul><pre>@Component<br>public class CalculatorTools {<br><br>    @McpTool(name = &quot;add&quot;, description = &quot;Add two numbers together&quot;)<br>    public int add(<br>            @McpToolParam(description = &quot;First number&quot;, required = true) int a,<br>            @McpToolParam(description = &quot;Second number&quot;, required = true) int b) {<br>        System.out.println(&quot;Adding &quot; + a + &quot; and &quot; + b);<br>        return a + b;<br>    }<br>}</pre><p><strong>Update application.properties</strong></p><pre>spring.application.name=mcp-server<br>server.port=9091<br><br>spring.ai.mcp.server.type=sync<br>spring.ai.mcp.server.annotation-scanner.enabled=true<br>spring.ai.mcp.server.protocol=streamable<br>spring.ai.mcp.server.streamable-http.keep-alive-interval=30s</pre><h3>MCP Client</h3><p>An <strong>MCP client with the Streamable API</strong> is basically a client application (like an IDE, web app, or agent) that connects to an <strong>MCP server</strong> using the <strong>Streamable HTTP transport</strong>.</p><p>Here’s what it means in practice:</p><ul><li><strong>Client role</strong> → The MCP client is the consumer. It makes HTTP POST and GET requests to the MCP server to invoke tools, fetch resources, or interact with prompts.</li><li><strong>Streamable API</strong> → Instead of waiting for a single response per request, the client can receive <strong>multiple messages over time</strong> from the server. This is possible because of <strong>Server-Sent Events (SSE)</strong> support in the Streamable transport.</li><li><strong>Why it matters</strong> → The client isn’t limited to one-off request/response cycles. The server can push updates dynamically (e.g., tool status changes, resource updates, or new prompts), and the client can handle them in near real time.</li><li><strong>Example use case</strong>:</li><li>An MCP client in a developer IDE subscribes to a code analysis tool.</li><li>The MCP server sends incremental analysis results via SSE.</li><li>The client UI updates continuously without polling</li></ul><p>So, an MCP client with the Streamable API is just a <strong>client that speaks HTTP + SSE with an MCP server</strong> and can handle <strong>ongoing streams of server events</strong>, not just single-shot responses.</p><pre>&lt;properties&gt;<br>    &lt;java.version&gt;25&lt;/java.version&gt;<br>    &lt;spring-ai.version&gt;1.1.0-M2&lt;/spring-ai.version&gt;<br>&lt;/properties&gt;<br><br> &lt;dependency&gt;<br>            &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>            &lt;artifactId&gt;spring-ai-starter-mcp-client&lt;/artifactId&gt;<br> &lt;/dependency&gt;<br><br>&lt;dependency&gt;<br>            &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>            &lt;artifactId&gt;spring-ai-starter-model-openai&lt;/artifactId&gt;<br> &lt;/dependency&gt;<br><br> &lt;dependencyManagement&gt;<br>        &lt;dependencies&gt;<br>            &lt;dependency&gt;<br>                &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>                &lt;artifactId&gt;spring-ai-bom&lt;/artifactId&gt;<br>                &lt;version&gt;${spring-ai.version}&lt;/version&gt;<br>                &lt;type&gt;pom&lt;/type&gt;<br>                &lt;scope&gt;import&lt;/scope&gt;<br>            &lt;/dependency&gt;<br>        &lt;/dependencies&gt;<br>    &lt;/dependencyManagement&gt;</pre><p><strong>Update application.properties</strong></p><pre>spring.application.name=mcp-client<br>server.port=9092<br><br>spring.ai.mcp.client.streamable-http.connections.server1.url=http://localhost:9091<br>spring.ai.mcp.client.streamable-http.connections.server1.endpoint=/mcp<br><br>spring.ai.openai.api-key=</pre><p><strong>Use ChatClient with openai to call mcp server add tool</strong></p><pre>@Bean<br>CommandLineRunner commandLineRunner( SyncMcpToolCallbackProvider toolCallbackProvider, ChatClient.Builder chatClientBuilder) {<br>    return args -&gt; {<br>        ToolCallback[] toolCallbacks = toolCallbackProvider.getToolCallbacks();<br>        ChatClient chatClient = chatClientBuilder.defaultToolCallbacks(toolCallbacks)<br>                .build();<br><br>        String response = chatClient.prompt(&quot;Using add tool, calculate 2 + 2 ?&quot;)<br>                .call()<br>                .content();<br>        System.out.println(response);<br>    };<br>}</pre><p>Github link: <a href="https://github.com/siddharth223437/spring-ai-example-apps">https://github.com/siddharth223437/spring-ai-example-apps</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3446d2c2079" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strategy Pattern with a Registry Pattern using SpringBoot]]></title>
            <link>https://medium.com/@sarathesid/strategy-pattern-with-a-registry-pattern-using-springboot-0aa46b1743e9?source=rss-481d7da9cbe2------2</link>
            <guid isPermaLink="false">https://medium.com/p/0aa46b1743e9</guid>
            <dc:creator><![CDATA[Siddharth Sarathe]]></dc:creator>
            <pubDate>Sat, 27 Sep 2025 04:32:44 GMT</pubDate>
            <atom:updated>2025-09-27T04:32:44.326Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a really common and powerful design approach in enterprise apps — especially when you want to dynamically pick an implementation at runtime without if/else clutter.</p><p><strong>Strategy Pattern Recap</strong></p><ul><li>You define a <strong>Strategy interface</strong> with one or more operations.</li><li>Multiple concrete implementations exist.</li><li>At runtime, the right strategy is chosen.</li></ul><p><strong>Registry Pattern Recap</strong></p><ul><li>A <strong>registry</strong> maintains a lookup (usually a Map) of available strategies keyed by some identifier (string, enum, type).</li><li>Instead of using if/else or switch, you fetch the strategy from the registry.</li></ul><p><strong>Putting Both Together in Spring Boot</strong></p><ol><li>Define the Strategy interface</li></ol><pre>public interface PaymentStrategy {<br>    String getType(); // e.g., &quot;CreditCard&quot;, &quot;Stripe&quot;, etc.<br>    void pay(double amount);<br>}</pre><p>2. Implement multiple strategies</p><pre>@Component<br>public class CreditCardPaymentStrategy implements PaymentStrategy{<br><br>    private final Logger logger = Logger.getLogger(CreditCardPaymentStrategy.class.getName());<br><br>    @Override<br>    public String getType() {<br>        return &quot;CREDIT_CARD&quot;;<br>    }<br><br>    @Override<br>    public void pay(double amount) {<br>        logger.info(&quot;Paying with credit card: $&quot; + amount);<br>    }<br>}<br><br><br><br>@Component<br>public class StripePaymentStrategy implements PaymentStrategy{<br><br>    private final Logger logger = Logger.getLogger(StripePaymentStrategy.class.getName());<br><br>    @Override<br>    public String getType() {<br>        return &quot;STRIPE&quot;;<br>    }<br><br>    @Override<br>    public void pay(double amount) {<br>        logger.info(&quot;Paying with stripe: $&quot; + amount);<br>    }<br>}</pre><p>3. Create a <strong>Registry</strong> that Spring auto-wires</p><pre>@Component<br>public class PaymentStrategyRegistry {<br><br>    private final Map&lt;String, PaymentStrategy&gt; strategies = new HashMap&lt;&gt;();<br><br>    public PaymentStrategyRegistry(List&lt;PaymentStrategy&gt; strategyList) {<br>        for (PaymentStrategy strategy : strategyList) {<br>            strategies.put(strategy.getType(), strategy);<br>        }<br>    }<br><br>    public PaymentStrategy getStrategy(String type) {<br>        return strategies.get(type);<br>    }<br>}</pre><p><em>Here, Spring injects </em><strong><em>all beans</em></strong><em> that implement </em><em>PaymentStrategy.<br> We populate the registry map at startup.</em></p><p>4. Use the registry in your service</p><pre>@Service<br>public class PaymentService {<br><br>    private final PaymentStrategyRegistry registry;<br><br>    public PaymentService(PaymentStrategyRegistry registry) {<br>        this.registry = registry;<br>    }<br><br>    public void processPayment(String type, double amount) {<br>        PaymentStrategy strategy = registry.getStrategy(type);<br>        if (strategy == null) {<br>            throw new IllegalArgumentException(&quot;No payment strategy found for type: &quot; + type);<br>        }<br>        strategy.pay(amount);<br>    }<br>}</pre><p>5. Example Controller</p><pre>@RestController<br>@RequestMapping(&quot;/api/payment&quot;)<br>public class PaymentController {<br><br>    private final PaymentService paymentService;<br><br>    public PaymentController(PaymentService paymentService) {<br>        this.paymentService = paymentService;<br>    }<br><br>    @PostMapping(&quot;/{type}&quot;)<br>    public String makePayment(@PathVariable String type, @RequestParam double amount) {<br>        paymentService.processPayment(type, amount);<br>        return &quot;Payment of &quot; + amount + &quot; processed via &quot; + type;<br>    }<br>}</pre><p><strong>Advantages</strong></p><ul><li><strong>Open/Closed Principle</strong> → Add new strategies without modifying service logic.</li><li><strong>No if/else soup</strong> → The registry selects implementations at runtime.</li><li><strong>Spring integration</strong> → Beans auto-discovered and registered.</li></ul><p><strong>Github Link</strong></p><p><a href="https://github.com/siddharth223437/architecture-patterns/tree/main/src/main/java/com/arc/patterns/strategy">https://github.com/siddharth223437/architecture-patterns/tree/main/src/main/java/com/arc/patterns/strategy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0aa46b1743e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>