<?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 Pabasara Mahindapala on Medium]]></title>
        <description><![CDATA[Stories by Pabasara Mahindapala on Medium]]></description>
        <link>https://medium.com/@pabasaramahindapala?source=rss-864232b60728------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7FPdJz7bLwtoW6XmRnyi3A.jpeg</url>
            <title>Stories by Pabasara Mahindapala on Medium</title>
            <link>https://medium.com/@pabasaramahindapala?source=rss-864232b60728------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 02:41:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pabasaramahindapala/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[Unlimited Tab Autocomplete with a Locally Run Model]]></title>
            <link>https://towardsdev.com/unlimited-tab-autocomplete-with-a-locally-run-model-ce2519e272fc?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce2519e272fc</guid>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[qwen]]></category>
            <category><![CDATA[autocomplete]]></category>
            <category><![CDATA[writing]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 10:56:01 GMT</pubDate>
            <atom:updated>2026-12-01T12:12:48.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1xmEp3clwnnF97gD.jpg" /></figure><p>I set up free, unlimited tab autocomplete in VS Code with Continue and Ollama, running Qwen2.5-Coder 1.5B locally.</p><p>You might wonder why tab autocomplete matters when there are coding tools like Claude Code or Codex that can write entire projects for you.</p><p>A fair amount of what I write in a day isn’t only code. It’s case comments, docs, notes, and emails that I don’t want an AI tool to write entirely.</p><p><strong>Tab autocomplete</strong> is the grey “ghost text” an editor like VS Code shows ahead of your cursor, which you accept by pressing <strong>Tab</strong> or <strong>Cmd + Right Arrow</strong>. In code, it can be the finishing to the loop you are writing. In text, it finishes the sentence you were already halfway through, which matters when you write the same kind of prose few times a day.</p><h3>The Setup</h3><p>Only three ingredients:</p><ul><li><strong>Ollama</strong> is an open-source tool that downloads language models and runs them locally, exposing them over a HTTP API on localhost:11434.</li><li><strong>Continue</strong> is an open-source VS Code extension for AI-assisted editing. It can point at any model provider, including a local Ollama server.</li><li><strong>Qwen2.5-Coder</strong> is an open-weight family of coding models from Alibaba’s Qwen team.</li></ul><p>I picked the <em>base</em> variant ( qwen2.5-coder:1.5b-base) which is trained for <strong>fill-in-the-middle (FIM)</strong> (they see the text before and after your cursor and predict what goes in the gap).</p><h3>Install Ollama and the model</h3><p>On macOS, with Homebrew:</p><pre>brew install ollama<br>brew services start ollama   # runs in the background and starts at login<br>ollama pull qwen2.5-coder:1.5b-base</pre><p>Run a quick FIM request to confirm the model works:</p><pre>curl -s localhost:11434/api/generate -d &#39;{<br>  &quot;model&quot;: &quot;qwen2.5-coder:1.5b-base&quot;,<br>  &quot;prompt&quot;: &quot;def is_prime(n):\n    &quot;,<br>  &quot;suffix&quot;: &quot;\n\nprint(is_prime(7))\n&quot;,<br>  &quot;stream&quot;: false<br>}&#39;</pre><p>It returned a correct is_prime body at 143 tokens per second.</p><h3>Point Continue at the model</h3><p>After installing the Continue extension, update the file, ~/.continue/config.yaml:</p><pre>name: Local<br>version: 1.0.0<br>schema: v1<br>models:<br>  - name: Qwen2.5-Coder 1.5B (local)<br>    provider: ollama<br>    model: qwen2.5-coder:1.5b-base<br>    apiBase: http://localhost:11434<br>    roles:<br>      - autocomplete<br>    defaultCompletionOptions:<br>      keepAlive: 900</pre><p>The autocomplete role is the only one I needed. Chat and agent work can stay with Claude Code or Codex.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/0*PjKt6ugfFVxQwJMb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HFi1NxXmz0EfNDbH.png" /></figure><h3>Result</h3><p>I measured the first 45 completion requests from VS Code using Ollama’s request log (This is on an M4 Pro MacBook with 24 GB memory).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*rXEck7rSMNGwPb7ZMCXTKQ.png" /></figure><p>So the suggestion is there by the time you pause while typing.</p><p>It works in Markdown as well as in code. The model is trained mostly on code, so treat it as a sentence finisher, not a sophisticated writer.</p><h3>Cost</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*qWV0K1NFjZB3vD0Mms1xyA.png" /></figure><p>On Apple Silicon the GPU shares memory with everything else, so that 1.3 GB comes out of the same 24 GB that everything else on the machine uses. In practice, 1.3 GB is small enough that I don’t notice it. You can run a larger model if you have more memory.</p><h3>keep-alive</h3><p>Ollama unloads a model after 5 minutes without requests by default. But Continue sends its own keep-alive value with every request and overrides Ollama’s default.</p><p>I set it to 15 minutes with keepAlive: 900 in the config.yaml shown above. So if I stop using it for a while, the model unloads and frees the memory. When I start typing again, it loads back in about 1.5 seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/0*B07CUSuhNWL6qfDB.png" /></figure><p>Run ollama stop qwen2.5-coder:1.5b-base to unload the model and free the memory immediately.</p><p>That’s it!</p><p>The biggest takeaway is that you can have a free, unlimited tab autocomplete in VS Code without anything leaving your machine, and it is fast enough to be useful.</p><p><em>Originally published at </em><a href="https://pabasara-mahindapala.github.io/writing/local-tab-autocomplete-continue-ollama/"><em>https://pabasara-mahindapala.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce2519e272fc" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/unlimited-tab-autocomplete-with-a-locally-run-model-ce2519e272fc">Unlimited Tab Autocomplete with a Locally Run Model</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Turning WSO2 Identity Server’s SCIM 2.0 APIs into a governed MCP server with the WSO2 AI Gateway]]></title>
            <link>https://medium.com/@pabasaramahindapala/turning-wso2-identity-servers-scim-2-0-apis-into-a-governed-mcp-server-with-the-wso2-ai-gateway-df30c5a0cdc0?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/df30c5a0cdc0</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[scim]]></category>
            <category><![CDATA[wso2]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Tue, 03 Nov 2026 17:08:30 GMT</pubDate>
            <atom:updated>2026-11-03T17:08:30.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CY6DXQ4t5AUlO94s.jpg" /></figure><p>Photo by <a href="https://unsplash.com/@czapp_arpad">Árpád Czapp</a> on <a href="https://unsplash.com/photos/a-row-of-black-metal-turnstones-in-a-building-eXZQIKHj5lY">Unsplash</a></p><p><strong>TL;DR:</strong> <em>How to expose the SCIM 2.0 APIs of WSO2 Identity Server 7.3 as an MCP server, secure it with Identity Server’s own tokens at the WSO2 AI Gateway, and let an MCP client like Claude Desktop manage users and groups.</em></p><p>In this guide, we expose the SCIM 2.0 APIs of WSO2 Identity Server as an MCP server, and serve that MCP server through the WSO2 AI Gateway. The gateway accepts only callers holding Identity Server tokens, and lets each caller use only the tools its token’s scopes allow. At the end, we let Claude Desktop manage users and groups in IS through the MCP.</p><ul><li><strong>WSO2 Identity Server (IS)</strong> is WSO2’s open-source identity and access management server. It stores the users and groups, and issues the OAuth2 tokens used in this guide.</li><li><strong>SCIM 2.0</strong> (System for Cross-domain Identity Management) is the standard REST API for managing users and groups. IS serves it under /scim2.</li><li><strong>WSO2 AI Gateway</strong> is a single control plane for AI traffic, covering both LLM consumption (outbound) and MCP tool exposure (inbound). This guide uses the inbound side: the gateway sits in front of the MCP server and applies authentication and authorization policies to each request.</li><li><strong>Claude Desktop</strong> is Anthropic’s desktop app for Claude. It can be used as an MCP client.</li></ul><h3>Why</h3><p><em>If done securely, identity administration is a good fit for an AI agent.</em></p><p>“Create accounts for Liam and Olivia, put them in Support with Emma, and mark Liam as a gold-tier EU customer” is one sentence to tell your agent, but half a dozen SCIM calls with ids and JSON patch bodies.</p><p>Identity Server already has the REST APIs (SCIM 2.0 for users, groups, roles and more), and agents speak the Model Context Protocol (MCP), an open protocol that lets AI applications discover and call tools exposed by an MCP server. This setup meets two requirements:</p><ol><li>Turn those REST APIs into MCP tools <strong>without writing a custom server</strong>.</li><li><strong>Govern</strong> access: allow only callers holding Identity Server tokens, and only the tools those tokens’ scopes allow.</li></ol><h3>Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MYH5dywLDrUpM_UP.png" /></figure><p>There are <strong>two identities</strong> involved in the design:</p><ul><li><strong>The client</strong> (Claude Desktop or your AI assistant) gets a token from IS. The gateway validates it and verifies its scopes per tool.</li><li><strong>The MCP server</strong> calls Identity Server with its own <em>SCIM MCP Backend</em> credentials (a client-credentials token).</li></ul><p>Per-client authorization therefore happens at the gateway, not in Identity Server.</p><h3>Security model</h3><p>The gateway enforces access with two policies: mcp-auth validates the caller&#39;s token, and mcp-authz checks that the token has the scope each tool requires. Here is one call, delete_user, end to end. Note the two different tokens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6XQ44OYlzDKpWzAD.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/308658c7168c642a244371441a9608de/href">https://medium.com/media/308658c7168c642a244371441a9608de/href</a></iframe><p>Steps 5 and 6 configure the two gateway policies, and Step 3 defines what each tool returns.</p><p>The repository, <a href="https://github.com/pabasara-mahindapala/wso2is-scim2-mcp-ai-gateway">wso2is-scim2-mcp-ai-gateway</a>, has the specs and configuration used here.</p><p><a href="https://github.com/pabasara-mahindapala/wso2is-scim2-mcp-ai-gateway">GitHub - pabasara-mahindapala/wso2is-scim2-mcp-ai-gateway: WSO2 Identity Server 7.3 SCIM 2.0 APIs as an MCP server, generated with arazzo-mcp-gen and secured at the WSO2 AI Gateway with Identity Server tokens and per-tool scopes.</a></p><h3>Versions used</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa8a9c86bf1e32bba71fb9b182e47ca0/href">https://medium.com/media/aa8a9c86bf1e32bba71fb9b182e47ca0/href</a></iframe><h3>Prerequisites</h3><ul><li>Docker with Compose.</li><li><strong>JDK 21 or newer</strong> for Identity Server 7.3.</li><li>Node.js for <a href="https://www.npmjs.com/package/@modelcontextprotocol/inspector">MCP Inspector</a>, a browser-based tool from the MCP project for connecting to an MCP server, listing its tools and calling them.</li></ul><h3>Step 1: Run Identity Server 7.3 locally</h3><p>Download the IS 7.3.0 pack from <a href="https://wso2.com/identity-platform/identity-server/">here</a> and unzip it.</p><pre>sh bin/wso2server.sh start        # logs: repository/logs/wso2carbon.log</pre><p>Everything else in this setup runs in containers, so first confirm that a container can reach IS on the host:</p><pre>docker run --rm curlimages/curl -sk -o /dev/null -w &#39;%{http_code}\n&#39; https://host.docker.internal:9443/oauth2/jwks<br># 200</pre><p>host.docker.internal is a special hostname that resolves to the host machine from inside a container. Inside a container, localhost is the container itself, so containers in this guide reach IS at host.docker.internal:9443. Docker Desktop and Rancher Desktop provide it by default; on Linux with Docker Engine, add --add-host=host.docker.internal:host-gateway to docker run.</p><h3>Step 2: Applications and scopes in Identity Server</h3><p>For the two identities, create two machine-to-machine (M2M) applications in the Console ( <strong>Applications → New Application → M2M Application</strong>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01043ebb29959c285d31b1c7a8d747a7/href">https://medium.com/media/01043ebb29959c285d31b1c7a8d747a7/href</a></iframe><p>On each app’s <strong>Authorization</strong> tab ( <strong>Authorize resource</strong>), authorize the five SCIM2 API resources with all of their scopes: Users, Groups, Roles V1/V2, Bulk and Agents:</p><p>Each SCIM2 API is listed twice: /scim2/... for the root organization and /o/scim2/... for sub-organizations. Pick the /scim2/... one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0IOVnb6HtZRb8sZi.png" /></figure><p>On the <strong>Protocol</strong> tab, set the access token type to <strong>JWT</strong>. The gateway validates tokens locally against IS’s public keys from the JWKS endpoint.</p><p>A client-credentials token can then ask for the scopes it needs:</p><pre>curl -sk -u &quot;$CLIENT_ID:$CLIENT_SECRET&quot; https://localhost:9443/oauth2/token \<br>  -d grant_type=client_credentials \<br>  --data-urlencode &quot;scope=internal_user_mgt_list internal_user_mgt_view&quot;</pre><p>These scopes are self-descriptive. A read-only token can list users, but creating one is refused:</p><p>Eg:</p><pre>{&quot;schemas&quot;:[&quot;urn:ietf:params:scim:api:messages:2.0:Error&quot;],<br> &quot;detail&quot;:&quot;Operation is not permitted. You do not have permissions to make this request.&quot;,&quot;status&quot;:403}</pre><h3>Step 3: From OpenAPI + Arazzo to an MCP server</h3><p>The self hosted AI Gateway doesn’t turn REST into MCP by itself; it governs MCP servers. The provided tool for creating an MCP server from an existing REST API is <a href="https://github.com/wso2/arazzo-mcp-generator">arazzo-mcp-gen</a>, a WSO2 command-line tool. <a href="https://spec.openapis.org/arazzo/latest.html">Arazzo</a> is an OpenAPI Initiative specification for describing <em>workflows</em>: sequences of calls to operations defined in OpenAPI files. You give arazzo-mcp-gen OpenAPI specs plus an Arazzo file, and it builds a Dockerised Python MCP server. <strong>Each Arazzo workflow becomes one MCP tool.</strong></p><h3>Modifying the IS OpenAPI specs</h3><p>The generated server runs the workflows with arazzo-runner, a library that executes Arazzo workflows and reads authentication and server details straight from the OpenAPI files. Before generating, make three changes to the IS OpenAPI specs. The modified specs are in the repository&#39;s folder, with a comment on each change:</p><ol><li><strong>OAuth2 flow.</strong> The specs declare an authorizationCode flow. For a machine-to-machine backend, it needs to be changed to clientCredentials with tokenUrl: https://&lt;is-host&gt;:9443/oauth2/token. The runner then fetches tokens itself, using SCIM_OAUTH2_CLIENT_ID and SCIM_OAUTH2_CLIENT_SECRET. arazzo-runner show-env-mappings &lt;file&gt; prints these variable names.</li><li><strong>Scopes.</strong> The Arazzo runner requests only the scopes listed under the spec’s security requirement, and the IS specs list none (OAuth2: []). Without modifying this you get a token with no IS scopes, and IS returns 403 on every call. So scopes should be listed. e.g. internal_user_mgt_list.</li><li><strong>The server URL.</strong> arazzo-runner 0.9.6 builds URLs incorrectly from templated server URLs like https://{serverUrl}/t/{tenantDomain}/scim2. With variables in the host it repeats the path; with variables only in the path it never fills them in. The fix is adding the literal server URL: <a href="https://host.docker.internal:9443/scim2.">https://host.docker.internal:9443/scim2.</a></li></ol><h3>What the generated tools look like to your MCP client</h3><p>Some behaviour worth knowing before you design MCP tools:</p><ul><li><strong>The tool description is the workflow </strong><strong>summary.</strong> The longer description field is used only when summary is empty, so put the LLM-facing explanation in summary.</li><li><strong>Input descriptions aren’t sent to the MCP client.</strong> Each tool parameter has only a name and a type, so explain the inputs in summary too.</li><li><strong>Every input is required.</strong> There are no optional parameters. Omitting attributes fails schema validation, and passing &quot;&quot; makes IS reject the filter. (Look at how listing and searching tools are split into separate tools).</li><li><strong>Results are a stringified Python dict</strong>, not JSON.</li><li><strong>IS errors can come back as “Workflow Success”.</strong> A 4xx error from IS is returned as text, with MCP isError: false. The LLM can read the SCIM error only <em>if your outputs include it</em>. See <a href="https://pabasara-mahindapala.github.io/writing/wso2-is-scim2-mcp-server-ai-gateway/#map-errors-into-the-outputs">Map errors into the outputs</a>.</li><li>The Arazzo runner requests a new token for every tool call (no caching).</li></ul><h3>Designing the full tool set</h3><p>The repository’s <a href="https://github.com/pabasara-mahindapala/wso2is-scim2-mcp-ai-gateway/blob/master/arazzo/is-scim2.arazzo.yaml">is-scim2.arazzo.yaml</a> defines 21 small, task-shaped workflows instead of mirroring every endpoint exactly. Your LLM picks tools better when they are mapped to the actual tasks you want it to perform.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/423f924e99409f42de2305cc276b51da/href">https://medium.com/media/423f924e99409f42de2305cc276b51da/href</a></iframe><p>Each workflow has the same shape. This is search_users, which calls POST /scim2/Users/.search (shortened):</p><pre>workflows:<br>  - workflowId: searchUsers<br>    summary: &gt;                       # &lt;- this becomes the tool description<br>      Search users with a SCIM filter, e.g. &#39;userName eq emma.clarke&#39;, &#39;userName sw em&#39;, …<br>      If error is set (not None), the call failed and error says why.<br>    inputs:<br>      type: object<br>      properties:<br>        filter: { type: string, description: SCIM filter expression }<br>        count: { type: integer, description: Maximum number of users to return }<br>    steps:<br>      - stepId: search<br>        operationId: getUsersByPost<br>        requestBody:<br>          contentType: application/scim+json<br>          payload:<br>            schemas: [&quot;urn:ietf:params:scim:api:messages:2.0:SearchRequest&quot;]<br>            filter: $inputs.filter<br>            count: $inputs.count<br>        successCriteria:<br>          - condition: $statusCode == 200<br>        outputs:<br>          error: $response.body#/detail<br>          errorStatus: $response.body#/status<br>          users: $response.body#/Resources<br>    outputs:<br>      error: $steps.search.outputs.error<br>      errorStatus: $steps.search.outputs.errorStatus<br>      users: $steps.search.outputs.users</pre><p>Two Arazzo features matter here:</p><ul><li><strong>A two-step tool.</strong> Identity Server needs the member’s display (userName) as well as its id when adding someone to a group. So add_user_to_group first looks the user up, then sends the PATCH. The LLM only provides two ids.</li></ul><pre>steps:<br>  - stepId: lookupUser<br>    operationId: getUserById<br>    parameters: [{ name: id, in: path, value: $inputs.userId }]<br>    outputs: { userName: $response.body#/userName }<br>  - stepId: addMember<br>    operationId: patchGroup<br>    requestBody:<br>      payload:<br>        schemas: [&quot;urn:ietf:params:scim:api:messages:2.0:PatchOp&quot;]<br>        Operations:<br>          - op: add<br>            value:<br>              members:<br>                - value: $inputs.userId<br>                  display: $steps.lookupUser.outputs.userName</pre><ul><li>The <a href="https://marketplace.visualstudio.com/items?itemName=WSO2.arazzo-visualizer">Arazzo Visualizer</a> extension for VS Code draws the workflow as a diagram, which makes the step chain easier to check than the YAML ( <a href="https://medium.com/@himethkbw/from-openapi-endpoints-to-runnable-api-workflows-introducing-arazzo-visualizer-for-vs-code-6a73b6d4b6c6">introduction to the extension</a>):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qiv8ME8nAs1ikMdQ.png" /></figure><ul><li><strong>Deciding what the LLM sees.</strong> Creating an agent returns its generated password in the response. But the create_agent tool outputs only id and userName ($response.body#/id), so the password never enters the LLM&#39;s context.</li></ul><h3>Map errors into the outputs</h3><p>IS reports a failed call as a SCIM error body, and the generated tool still returns “Workflow Success” with isError: false. So map the error fields into every workflow&#39;s outputs, as search_users does above:</p><pre>outputs:<br>  error: $response.body#/detail<br>  errorStatus: $response.body#/status</pre><p>and tell the LLM how to read them in the summary: &quot;If error is set (not None), the call failed and error says why.&quot;</p><p>A workflow that returns the whole response body, like get_user, also carries the error:</p><pre>get_user(userId=&quot;0000…&quot;)  →  isError: false<br>Workflow Success. Outputs: {&#39;user&#39;: {&#39;schemas&#39;: [&#39;urn:ietf:params:scim:api:messages:2.0:Error&#39;],<br>  &#39;detail&#39;: &#39;User 0000… does not exist in: PRIMARY&#39;, &#39;status&#39;: &#39;404&#39;}}</pre><p>A workflow that maps only selected fields, without error, hides the failure from the LLM. Step 7 shows Claude correcting its own request from one of these errors.</p><h3>Custom profile attributes</h3><p>update_user_profile sets standard and custom attributes together. First, add two custom attributes to the IS user profile:</p><p>Creating a new attribute in the Console ( <strong>User Attributes &amp; Stores → Attributes</strong>) maps it to the SCIM custom schema:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gEpOo75ZQ_UqCtU3.png" /></figure><p>The update_user_profile tool then updates the user attributes in a single PATCH:</p><pre>Operations:<br>  - op: replace<br>    value:<br>      addresses:<br>        - type: work<br>          formatted: $inputs.region<br>      &quot;urn:ietf:params:scim:schemas:extension:enterprise:2.0:User&quot;:<br>        department: $inputs.department<br>        employeeNumber: $inputs.employeeNumber<br>        costCenter: $inputs.costCenter<br>      &quot;urn:scim:schemas:extension:custom:User&quot;:<br>        customerTier: $inputs.customerTier<br>        contractEndDate: $inputs.contractEndDate</pre><p>list_users and search_users return these attributes, and the search_users description gives the LLM working filter examples for each kind.</p><pre>addresses.work eq EU<br>urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:department eq Finance<br>urn:scim:schemas:extension:custom:User:customerTier eq gold</pre><h3>Generate and run</h3><p>First validate and inspect the workflows:</p><pre>arazzo-mcp-gen validate -f arazzo<br>arazzo-mcp-gen inspect -f arazzo</pre><p>inspect prints a summary of the Arazzo file without generating anything: the source OpenAPI specs, and for each of the 21 workflows its inputs, steps and outputs. Each workflow listed here becomes one MCP tool, so this is a quick check of what the MCP client will get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AbjMDyS-5sKjk3t8.png" /></figure><p>Then generate the server and run it. The image is named after the Arazzo info.title value:</p><pre>arazzo-mcp-gen mcp-server generate -f arazzo -p 5000 -o generated   # also runs docker build<br><br>docker run -d --name scim-mcp-server -p 127.0.0.1:5050:5000 \<br>  -e ARAZZO_DISABLE_TLS_VERIFY=1 \<br>  -e SCIM_OAUTH2_CLIENT_ID=... -e SCIM_OAUTH2_CLIENT_SECRET=... \<br>  -e AI_OAUTH2_CLIENT_ID=...   -e AI_OAUTH2_CLIENT_SECRET=... \<br>  is-scim2-mcp-mcp-server</pre><p>Both credential pairs are from the <em>SCIM MCP Backend</em> app we created.</p><h3>Step 4: Put the AI Gateway in front</h3><p>Setup the AI Gateway distribution first.</p><pre>ADMIN_USERNAME=admin ADMIN_PASSWORD=&#39;&lt;strong-password&gt;&#39; ./scripts/setup.sh</pre><p>Before starting it, configure the gateway to trust tokens from Identity Server. These settings are system parameters of the mcp-auth policy (v1.4.0), not part of config-template.toml, so append them to configs/config.toml (the snippet is <a href="https://github.com/pabasara-mahindapala/wso2is-scim2-mcp-ai-gateway/blob/master/gateway/is-keymanager.toml">gateway/is-keymanager.toml</a> in the repository):</p><pre>[[policy_configurations.jwtauth_v1.keymanagers]]<br>name = &quot;WSO2IS&quot;<br>issuer = &quot;https://localhost:9443/oauth2/token&quot;      # must equal the token&#39;s issuer<br><br>[policy_configurations.jwtauth_v1.keymanagers.jwks.remote]<br>uri = &quot;https://host.docker.internal:9443/oauth2/jwks&quot;  # fetched from inside the container<br>skipTlsVerify = true                                   # IS self-signed cert, local only<br><br>[policy_configurations.mcpauth_v1]<br>gatewayurl = &quot;https://localhost:8443&quot;</pre><p>Here, the issuer must match what IS adds in tokens, and the JWKS URL must be reachable from inside the container.</p><p>Next we start the gateway and the MCP server:</p><pre>docker compose up -d<br>curl -s http://localhost:8080/_gateway-health/healthy   # {&quot;status&quot;:&quot;healthy&quot;}<br>docker network connect &lt;project&gt;_gateway-network scim-mcp-server</pre><p>The last command puts the generated MCP server on the gateway’s network so the proxy can reach it as <a href="http://scim-mcp-server:5000/mcp.">http://scim-mcp-server:5000/mcp.</a></p><h3>Register the MCP proxy</h3><p>The gateway only needs to know where the MCP server is. It doesn’t care that REST, OpenAPI or Arazzo sit behind it:</p><pre>apiVersion: gateway.api-platform.wso2.com/v1<br>kind: Mcp<br>metadata:<br>  name: is-scim2-mcp-v1.0<br>spec:<br>  displayName: IS SCIM2 MCP<br>  version: v1.0<br>  context: /scim<br>  specVersions: [&quot;2025-06-18&quot;, &quot;2025-11-25&quot;]   # specVersion (singular) is deprecated<br>  upstream:<br>    url: http://scim-mcp-server:5000/mcp      # forwarded to exactly this URL<br>  tools: []<br>  resources: []<br>  prompts: []</pre><p>Make the following request to register the MCP proxy. The full definition, including the policies added in Steps 5 and 6, is <a href="https://github.com/pabasara-mahindapala/wso2is-scim2-mcp-ai-gateway/blob/master/gateway/mcp-proxy.yaml">gateway/mcp-proxy.yaml</a>:</p><pre>curl -u admin:&lt;password&gt; -X POST http://localhost:9090/api/management/v1/mcp-proxies \<br>  -H &#39;Content-Type: application/yaml&#39; --data-binary @mcp-proxy.yaml      # 201, state: deployed</pre><p>Clients now connect to <a href="https://localhost:8443/scim/mcp.">https://localhost:8443/scim/mcp.</a></p><p>We can use MCP Inspector to list the tools and verify.</p><p>To open MCP Inspector against the gateway’s self-signed certificate, you will need to trust that certificate:</p><pre>NODE_EXTRA_CA_CERTS=resources/listener-certs/default-listener.crt npx @modelcontextprotocol/inspector@2.8.0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nUb-2K5z4duu91Ev.png" /></figure><p>At this point the gateway just a pass-through without any security for the MCP server. Anyone who can reach port 8443 can call the tools. Next steps fix that.</p><h3>Step 5: Secure it with Identity Server tokens</h3><p>Adding the mcp-auth policy on the proxy turns the gateway into an OAuth-protected MCP resource that trusts Identity Server:</p><pre>policies:<br>    - name: mcp-auth<br>      version: v1<br>      params:<br>        issuers: [WSO2IS]            # the key manager from config.toml<br>        audiences:<br>          - &lt;SCIM MCP Client client_id&gt;<br>        requiredScopes: [internal_user_mgt_view, …]</pre><p>Without a token, the gateway answers the way the MCP authorization spec expects:</p><pre>HTTP/2 401<br>www-authenticate: Bearer resource_metadata=&quot;https://localhost:8443/scim/.well-known/oauth-protected-resource&quot;,<br>                  scope=&quot;internal_user_mgt_view internal_user_mgt_list …&quot;, error=&quot;invalid_token&quot;</pre><pre>GET /scim/.well-known/oauth-protected-resource<br>{<br>  &quot;resource&quot;: &quot;https://localhost:8443/scim/mcp&quot;,<br>  &quot;authorization_servers&quot;: [&quot;https://localhost:9443/oauth2/token&quot;],<br>  &quot;scopes_supported&quot;: [&quot;internal_user_mgt_view&quot;, &quot;…&quot;]<br>}</pre><p>The authorization server is the key manager’s issuer. IS 7.3 serves RFC 8414 metadata at the path (/.well-known/oauth-authorization-server/oauth2/token), with authorize, token, PKCE and a dynamic client registration endpoint. So the whole discovery chain an MCP client follows resolves against IS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SXOTbh9jDQUrwJnh.png" /></figure><p>Set audiences to the <em>SCIM MCP Client</em> app&#39;s client_id. IS puts the client&#39;s client_id in the token&#39;s aud claim, and mcp-auth passes audiences to the underlying jwt-auth policy, which checks it. This is required so that a token from any IS application is not accepted; with this in place, the backend app&#39;s token fails with 401.</p><p>In this flow, the caller’s (MCP client’s) token never actually reaches the MCP server. mcp-auth policy defaults to forwardToken: false. That&#39;s the two-identity model we&#39;re using. The AI gateway authenticates the caller, and the MCP server talks to IS with its own credential.</p><p>In MCP Inspector, call create_user with a bearer token from the <em>SCIM MCP Client</em> app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fzCYV8lMdcDtEr03.png" /></figure><p>The user appears in the Identity Server Console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gBXsQBECYLLyJ25a.png" /></figure><h3>Step 6: Per-tool authorization</h3><p>Authentication tells the gateway <em>who</em> is calling. mcp-authz decides <em>which tools</em> they may call, using the scopes in the IS token. Each tool is defined with the exact scope IS itself requires for the SCIM operation behind it, so the gateway&#39;s rules and Identity Server&#39;s own API authorization line up:</p><pre>- name: mcp-authz<br>      version: v1<br>      params:<br>        tools:<br>          - name: search_users<br>            scopes: { allOf: [internal_user_mgt_list] }<br>          - name: delete_user<br>            scopes: { allOf: [internal_user_mgt_delete] }<br>          - name: add_user_to_group          # reads the user, then patches the group<br>            scopes: { allOf: [internal_user_mgt_view, internal_group_mgt_update] }<br>          - name: assign_role_to_user<br>            scopes: { anyOf: [internal_role_mgt_update, internal_role_mgt_users_update] }<br>          # … one rule for each of the 21 tools</pre><p>A read-only token (view/list scopes only) can still search for a user, but deleting the user is stopped at the gateway, before the call reaches the MCP server or IS:</p><pre>HTTP/2 403<br>www-authenticate: Bearer resource_metadata=&quot;…/scim/.well-known/oauth-protected-resource&quot;,<br>                  scope=&quot;internal_user_mgt_delete&quot;, error=&quot;insufficient_scope&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GgzEoajNl5GyQaJu.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z8WdSz6l3ZnHT3wq.png" /></figure><p>Here, the scope in the www-authenticate challenge names what&#39;s missing, so a client could retry with the missing scope.</p><p>How the rules apply to narrower tokens:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a369fc2bb10c6db9c97ef6f35f1255e/href">https://medium.com/media/4a369fc2bb10c6db9c97ef6f35f1255e/href</a></iframe><h3>Step 7: Try it out with the actual MCP client</h3><p>Claude Desktop runs local MCP servers over stdio, so a small bridge, , connects it to the gateway’s HTTPS endpoint.</p><p>My article <a href="https://pabasara-mahindapala.github.io/writing/connecting-mcp-server-claude-desktop-claude-code/">Testing Your Local MCP Server with Claude Desktop and Claude Code</a> explains how to set up mcp-remote in claude_desktop_config.json, step by step.</p><p>The MCP server is configured in the Claude Desktop’s claude_desktop_config.json file as explained in the article.</p><pre>&quot;mcpServers&quot;: {<br>  &quot;is-scim&quot;: {<br>    &quot;command&quot;: &quot;/opt/homebrew/bin/npx&quot;,<br>    &quot;args&quot;: [&quot;-y&quot;, &quot;mcp-remote@0.14.3&quot;, &quot;https://localhost:8443/scim/mcp&quot;,<br>             &quot;--transport&quot;, &quot;http-only&quot;,<br>             &quot;--header-file&quot;, &quot;/Users/&lt;you&gt;/Library/Application Support/Claude/is-scim-mcp/headers&quot;],<br>    &quot;env&quot;: {<br>      &quot;NODE_EXTRA_CA_CERTS&quot;: &quot;/Users/&lt;you&gt;/Library/Application Support/Claude/is-scim-mcp/gateway-listener.crt&quot;,<br>      &quot;PATH&quot;: &quot;/opt/homebrew/bin:/usr/bin:/bin&quot;<br>    }<br>  }<br>}</pre><p>Note the following:</p><ul><li><strong>The token lives in a header file</strong>, not in the config. --header-file keeps it out of the config and out of the process list.</li><li><strong>The gateway certificate should be trusted</strong> with NODE_EXTRA_CA_CERTS, which points to a copy of the gateway&#39;s listener certificate, instead of turning off TLS checks with NODE_TLS_REJECT_UNAUTHORIZED=0.</li><li><strong>mcp-remote version is pinned</strong></li></ul><p>After restarting Claude Desktop, the 21 tools will show up in the tools menu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WuWWgHPJLlg9pCGf.png" /></figure><p>Sample prompt to try in Claude Desktop:</p><blockquote><em>Create a group called Support Team, create users Liam Turner and Olivia Bennett, and add both of them plus Emma Clarke to Support Team. Set Liam’s region to EU and customer tier to gold.</em></blockquote><p>Claude got the error: &quot;Group name Support Team is not valid ... ^[\S]{3,30}$&quot; and chose to use Support-Team instead. Claude could correct the request only because create_group maps the error into its outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FGPoZ3jJYdEW59xG.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zghWT21W43TKZzvO.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YGTKydOzNUfNhc5w.png" /></figure><p>Now the group and users are in Identity Server, and Liam’s profile has region EU and customerTier: gold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4Q9mjukT0WCoy434.png" /></figure><h3>Conclusion</h3><p>We exposed the SCIM 2.0 APIs of WSO2 Identity Server as 21 MCP tools without writing a server: arazzo-mcp-gen generated it from the IS OpenAPI specs and an Arazzo file. The WSO2 AI Gateway in front of it accepts only Identity Server tokens issued to the <em>SCIM MCP Client</em> app, and allows each tool only when the token carries the IS scope that the tool&#39;s SCIM operation needs. Claude Desktop then managed users and groups from plain natural language requests, within those limits.</p><p>The gateway governs the MCP server but doesn’t create it; the Arazzo file is where the tool design lives. Three points from that design apply to any REST API you expose this way:</p><ul><li><strong>Design tools for the model, not for the API.</strong> Task-shaped tools such as add_user_to_group and update_user_profile hide the SCIM PATCH syntax, member display values and URN-qualified attribute names. The summary is the only documentation the model gets, so put examples and constraints there.</li><li><strong>Map errors into the outputs.</strong> Failed calls can still report “Workflow Success”, so the model sees why a call failed only if the outputs include the error.</li><li><strong>Return only what the model needs.</strong> create_agent maps only id and userName, so the generated password never reaches the LLM.</li></ul><p>Plan around the current Arazzo limits: object and array inputs are passed as plain strings, all inputs are required, and results come back as a stringified Python dict, not JSON.</p><h3>What’s next</h3><p><strong>Interactive OAuth instead of pasted tokens.</strong></p><p>The gateway uses Identity Server as the authorization server, and an MCP client that does the full OAuth flow could sign the user in, rather than pasting an M2M token. This needs an application in IS that supports the authorization code flow with PKCE, because our M2M application supports only client credentials.</p><p>The gateway checks the token the same way whatever the grant type, but IS grants only the scopes the signed-in user’s roles allow, so per-tool access can follow each user’s own permissions. Identity Server would still see every call as the SCIM MCP Backend app, because the user’s token stops at the gateway (forwardToken: false).</p><p><em>Originally published at </em><a href="https://pabasara-mahindapala.github.io/writing/wso2-is-scim2-mcp-server-ai-gateway/"><em>https://pabasara-mahindapala.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df30c5a0cdc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[mcp-remote Crashed When the OAuth Port Was Taken, Here’s How I Fixed It]]></title>
            <link>https://towardsdev.com/mcp-remote-crashed-when-the-oauth-port-was-taken-heres-how-i-fixed-it-142630478746?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/142630478746</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 02:31:25 GMT</pubDate>
            <atom:updated>2026-12-01T12:12:20.023Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wQz2F8VIBdNjsrKA.jpg" /></figure><p><em>Why a port conflict crashed a package with millions of weekly downloads, and why the obvious fix was not right</em></p><p><strong>TL;DR:</strong> A stale process holding a port made mcp-remote crash on startup with EADDRINUSE. The obvious fix is to grab another port, but that quietly breaks OAuth. Here is why, and what I changed in <a href="https://github.com/punkpeye/mcp-remote/pull/262">PR #262</a>.</p><h3>The package</h3><p>If you have ever connected Claude Desktop to a remote <a href="https://modelcontextprotocol.io/docs/2026-07-28/getting-started/intro">MCP server</a>, you might have run mcp-remote.</p><p>Most MCP clients only support STDIO to a local process. Remote MCP servers require HTTP and expect a full OAuth flow. mcp-remote bridges the gap: it reads STDIO on one side and makes authenticated HTTP requests on the other side. A walkthrough of that setup is available in <a href="https://pabasara-mahindapala.github.io/software-development/2026/05/03/connecting-mcp-server-claude-desktop-claude-code/">Testing Your Local MCP Server with Claude Desktop and Claude Code</a>.</p><p>It runs a local HTTP server to capture the OAuth redirect, handles the browser authentication flow, and caches the resulting token for reuse.</p><p>The scale was impressive when I looked it up. The package has about 2 million downloads per week.</p><p>Most usages of the package are simple, define the remote MCP server URL and it’s good to go.</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;remote-example&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [&quot;mcp-remote&quot;, &quot;https://remote.mcp.server/mcp&quot;]<br>    }<br>  }<br>}</pre><h3>OAuth flow</h3><p>You see that the config above passes no credentials. By default mcp-remote registers itself with the authorization server at runtime through <a href="https://datatracker.ietf.org/doc/html/rfc7591">dynamic client registration</a>, gets its client_id, and caches it. Nothing needs to be set up in the server.</p><p>The package supports several additional flags in the OAuth flow:</p><ul><li><strong>--static-oauth-client-info</strong> hands it a pre-registered client_id and client_secret directly. Works against a provider that has no dynamic registration.</li><li><strong>--static-oauth-client-metadata</strong>, use this to pin a scope, or to override token_endpoint_auth_method when the server needs other values.</li><li><strong>--client-metadata-url</strong> uses a <a href="https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#overview">Client ID Metadata Document</a>, where an HTTPS URL is the client_id. No registration is required.</li><li><strong>--authorize-param key=value</strong> adds parameters to the authorize request. For example, Google needs access_type=offline and prompt=consent to issue a refresh token.</li></ul><p>A pre-registered client has a redirect_uri recorded against it, and a metadata document lists its own redirect_uris. The port defined in the redirect URI needs to be the same port that the mcp-remote callback server is listening on.</p><h3>The crash</h3><p>The callback port gets cached in mcp-remote to keep the OAuth redirect_uri stable across runs. On the next launch, mcp-remote reads the cached port and binds to it.</p><p>However, if a previous process crashed, by force-closing for example, its callback server is still holding that port. The old code called <a href="https://github.com/punkpeye/mcp-remote/blob/2899e55b43060ae906915b370cce513a9ad160f9/src/lib/utils.ts#L663">app.listen(port)</a> with no &#39;error&#39; handler.</p><p>When a port conflicts, the old code crashed with EADDRINUSE.</p><pre>[40217] Using existing client port: 28233 <br>[40217] Authentication required. Initializing auth... <br><br>Error: listen EADDRINUSE: address already in use 127.0.0.1:28233</pre><p>Since there was no recovery path, the only options were to hunt down the conflicting Node process, or manually edit your MCP config to use a different port. For anyone who did not know how it worked and the tool spawned a web server at all, it looked like the integration itself was broken. Nick Youngblut reported it as <a href="https://github.com/punkpeye/mcp-remote/issues/253">issue #253</a>.</p><h3>The obvious fix is wrong</h3><p>The tempting one-liner is to catch the error and bind port 0, letting the operating system assign a random port.</p><p>But that produces a working listener and a broken login.</p><p>The port is baked into the redirect_uri that was registered with the authorization server, and OAuth requires that value to match exactly at the token exchange. Rebinding makes the failure surface later, somewhere far from where the problem started.</p><p>So the fix has to answer a harder question than “is this port free?”. It has to decide whether the port is mandatory or incidental.</p><h3>The fix</h3><p>The change wraps app.listen() in a promise with an &#39;error&#39; handler, and splits on strictPort:</p><pre>httpServer.once(&#39;error&#39;, (err: NodeJS.ErrnoException) =&gt; {<br>  if (err.code === &#39;EADDRINUSE&#39;) {<br>    if (options.strictPort) {<br>      reject(/* actionable error naming the port */)<br>      return<br>    }<br>    log(`Warning: callback port ${options.port} is already in use, falling back to a random port`)<br>    const fallback = app.listen(0, &#39;127.0.0.1&#39;)<br>    fallback.once(&#39;listening&#39;, () =&gt; {<br>      const addr = fallback.address() as AddressInfo<br>      resolve({ server: fallback, actualPort: addr.port })<br>    })<br>  } else {<br>    reject(err)<br>  }<br>})</pre><p>See <a href="https://github.com/punkpeye/mcp-remote/blob/38f2e8b2ec7448c6f327e2583643bb35577e2c16/src/lib/utils.ts#L672-L708">src/lib/utils.ts</a>.</p><p><a href="https://github.com/punkpeye/mcp-remote/blob/38f2e8b2ec7448c6f327e2583643bb35577e2c16/src/lib/types.ts#L57">strictPort</a> is true when the user passed an explicit [callback-port] argument, or when --static-oauth-client-info is being used. Those are the cases where someone has told the authorization server what the exact redirect URI is. Rebinding to a different port would not work here. So it is set to <a href="https://github.com/punkpeye/mcp-remote/blob/38f2e8b2ec7448c6f327e2583643bb35577e2c16/src/lib/utils.ts#L678-L688">fail with a message naming the port</a> and why it is mandatory.</p><p>Otherwise the port was incidental, and the code repairs the situation. The real bound port travels back up through <a href="https://github.com/punkpeye/mcp-remote/blob/38f2e8b2ec7448c6f327e2583643bb35577e2c16/src/lib/coordination.ts#L168">coordinateAuth</a> as actualPort. The provider&#39;s redirect_uri is corrected through a new <a href="https://github.com/punkpeye/mcp-remote/blob/38f2e8b2ec7448c6f327e2583643bb35577e2c16/src/lib/node-oauth-client-provider.ts#L59">setCallbackPort()</a>. If dynamic registration is in use, the <a href="https://github.com/punkpeye/mcp-remote/blob/38f2e8b2ec7448c6f327e2583643bb35577e2c16/src/proxy.ts#L98">cached </a><a href="https://github.com/punkpeye/mcp-remote/blob/38f2e8b2ec7448c6f327e2583643bb35577e2c16/src/proxy.ts#L98">client_info.json is cleared</a> so the client can re-register with the actual address.</p><p><a href="https://github.com/punkpeye/mcp-remote/blob/38f2e8b2ec7448c6f327e2583643bb35577e2c16/src/lib/utils.test.ts#L1030-L1086">Three tests</a> cover the changes from the fix: actualPort matching the bound port, the fallback when the requested port is busy, and the rejection under strictPort.</p><p>Note that this fix is for the recovery, not complete prevention. A process that dies unexpectedly can still leave its callback server behind, and this change lets the mcp-remote client survive that without breaking.</p><p>The change merged on 21 August 2026 and shipped in 0.1.39.</p><h3>Conclusion</h3><p>The bug was larger than a missing error handler. The fix was mostly about noticing that a resource can be unavailable for different reasons, and the correct fix depends on whether that resource is part of an already established contract.</p><p><em>Originally published at </em><a href="https://pabasara-mahindapala.github.io/software-development/2026/09/07/mcp-remote-oauth-callback-port-crash/"><em>https://pabasara-mahindapala.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=142630478746" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/mcp-remote-crashed-when-the-oauth-port-was-taken-heres-how-i-fixed-it-142630478746">mcp-remote Crashed When the OAuth Port Was Taken, Here’s How I Fixed It</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Business Rules Don’t Have to Live in a Wiki Page: Enforcing Them with a Roslyn Analyzer]]></title>
            <link>https://towardsdev.com/business-rules-dont-have-to-live-in-a-wiki-page-enforcing-them-with-a-roslyn-analyzer-a10627874f5b?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/a10627874f5b</guid>
            <category><![CDATA[roslyn]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Mon, 17 Aug 2026 08:51:01 GMT</pubDate>
            <atom:updated>2026-09-18T12:05:22.814Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OpcGJZJ2iTkDiLe6.jpg" /></figure><p><em>How a .NET Roslyn analyzer moves a business-specific guardrail from developer memory into every build</em></p><p>Every codebase accumulates rules the compiler knows nothing about.</p><p>For example, money always goes through the Money type, never a raw decimal. Entities are constructed through their factory, not by hand. Endpoints return a DTO, never an entity straight out of the ORM.</p><p>These rules are load-bearing. Breaking one rarely produces a compiler complaint or a failing test, and the resulting code usually looks perfectly reasonable to a reviewer. So how do you actually enforce a rule your programming language knows nothing about?</p><p>Most teams keep them in a wiki page, an onboarding session, or a reminder pinned in the team channel. All of those enforce a rule the same way: by hoping people remember it. That works until the person who remembers is on leave, or is in a hurry, or left last year.</p><p>This is how you can stop relying on memory to enforce the rules that matter.</p><h3>A Sample Scenario: Two Layers of Authorization</h3><p>The rest of this article works through one sample scenario end to end.</p><p>Picture a multi-tenant platform: an ASP.NET Core application (.NET 8, MediatR for the request pipeline). Every tenant represents a “business,” and a single user can have roles across several businesses. So authorization has two distinct questions to answer on every request:</p><ol><li><strong>Can this user perform this action at all?</strong> (e.g. “Read a report,” “Add an invoice,” “Delete a user”)</li><li><strong>Can they perform it <em>for this specific business</em>?</strong> (the business ID sitting in the request)</li></ol><p>Question 1 is action-level. Question 2 is resource-level, and it’s the one that actually enforces tenant isolation. Get it wrong and a user who legitimately manages <em>their</em> business can reach into <em>someone else’s</em>.</p><p>Consider both questions are handled by an ASP.NET custom authorization attribute, and the resource-level check is on by default:</p><pre>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]<br>public class BusinessAuthorizeAttribute : Attribute, IAsyncAuthorizationFilter<br>{<br>    // Layer 1: does the user hold this capability at all?<br>    public string Action { get; set; }<br>    public string Feature { get; set; }<br><br>    // Layer 2: scope that capability to the business in the request.<br>    // On unless a call site turns it off.<br>    public bool CheckAgainstBusinessInRequest { get; set; } = true;<br><br>    public async Task OnAuthorizationAsync(AuthorizationFilterContext context)<br>    {<br>        // ... resolve the user, handle the super-admin bypass, etc.<br><br>        var businessId = await GetBusinessIdFromRequest(context.HttpContext);<br><br>        var hasPermission = await _permissions.CheckAsync(<br>            userId,<br>            CheckAgainstBusinessInRequest ? businessId : null,  // &lt;-- the crux<br>            Action,<br>            Feature);<br><br>        if (!hasPermission)<br>            throw new ForbiddenAccessException();<br>    }<br>}</pre><p>The third argument to the CheckAsync method is where tenant isolation lives:</p><ul><li>Pass the business ID, and the check asks: <em>“Does this user hold </em><em>{Action} on </em><em>{Feature} </em><strong><em>for this exact business</em></strong><em>?&quot;</em></li><li>Pass null, and it asks the much weaker question: <em>&quot;Does this user hold </em><em>{Action} on </em><em>{Feature} for </em><strong><em>any</em></strong><em> business at all?&quot;</em></li></ul><p>Note what happens when a request carries no business ID at all. GetBusinessIdFromRequest returns null, the check falls back to the general capability question, and the endpoint works normally. A DeleteInvoice(string id) action needs no special handling, which matters later.</p><h3>Why an Opt-Out Would Exist</h3><p>CheckAgainstBusinessInRequest = false disables the resource-level check even when the request <em>does</em> carry a business ID. That sounds like a footgun with no purpose, and it would be, except that a handful of operations genuinely need it.</p><p>The clearest case is a cross-business report. A user with access to several businesses opens a consolidated view, the request names one business as the anchor for the report, and the handler itself filters the results down to the businesses the caller is allowed to see. Applying the above attribute’s CheckAgainstBusinessInRequest check as well would reject perfectly legitimate requests.</p><p>One more example is an endpoint where the business ID in the request identifies something other than the tenant being authorized. In each case the opt-out is correct, and each endpoint carries this decision that only a human can make.</p><h3>The Trap</h3><p>Here are two endpoints. They look almost identical. Only one is safe.</p><pre>// Safe: the default scopes the check to the business in the request.<br>[BusinessAuthorize(Action = &quot;Add&quot;, Feature = &quot;Invoices&quot;)]<br>public Task&lt;IActionResult&gt; CreateInvoice(CreateInvoiceCommand request) =&gt;<br>    Mediator.Send(request);<br><br>// The trap: the request carries a BusinessId, but the check was turned off.<br>[BusinessAuthorize(Action = &quot;Add&quot;, Feature = &quot;Invoices&quot;,<br>                   CheckAgainstBusinessInRequest = false)]<br>public Task&lt;IActionResult&gt; CreateInvoice(CreateInvoiceCommand request) =&gt;<br>    Mediator.Send(request);</pre><p>Where the command carries the tenant identity:</p><pre>public class CreateInvoiceCommand : IRequest&lt;Envelope&lt;CreateInvoiceResponse&gt;&gt;<br>{<br>    public string BusinessId { get; set; }<br>    // ... invoice fields<br>}</pre><p>In the second version, a user who has the “Add Invoices” capability for <em>their own</em> business can send a request with a <strong>different</strong> business’s ID in the body. Layer 1 passes, because they do hold “Add Invoices” <em>somewhere</em>. But since Layer 2 has been switched off, nobody checks whether they hold it for the business they named. The command handler then happily writes an invoice into a tenant the caller was never entitled to.</p><p>This is textbook <strong>broken object-level authorization</strong>, a cross-tenant IDOR. It’s the kind of bug that is invisible in a typical demo, invisible in a happy-path unit test, and only shows up when someone goes looking.</p><p>The uncomfortable part is how such a line gets written in the first place. Nobody sets out to disable tenant isolation. What happens is that a developer hits a confusing 403 while building a feature, finds an attribute property that sounds related, sets it to false, watches the error disappear, and moves on. The change is small, deliberate, and confident.</p><p>Which brings us to the real question: where do you put a rule so that nobody can skip it?</p><h3>Where Do You Put a Rule So It Can’t Be Skipped?</h3><p><strong>Developer’s Memory</strong> is where a rule like this starts out. Every convention that isn’t enforced somewhere else ends up here by default.</p><p><strong>Documentation</strong> is memory with a URL. It’s genuinely useful for explaining <em>why</em>, and it is read approximately once, during onboarding, and then never again at the moment it matters.</p><p><strong>Code review</strong> is better, because a second pair of eyes sees the diff. But reviewers are inconsistent by nature. They catch the thing they’re primed to look for, and one extra property on an attribute that’s already there is not what anyone is scanning for.</p><p>But something sits even deeper: the <strong>compiler</strong>. It’s the one thing in the workflow that nobody can forget to invoke, because you cannot produce a running application without it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cy_9jXMuloBHTdzO.png" /></figure><h3>What a Roslyn Analyzer Actually Is</h3><p>Roslyn is the .NET compiler platform. Unlike a black-box compiler, it exposes the entire compilation as an API. You can walk the <strong>syntax tree</strong> (the literal structure of the code: attributes, methods, parameters) and query the <strong>semantic model</strong> (what those symbols actually resolve to, such as the real type behind CreateInvoiceCommand, including inherited members).</p><p>A DiagnosticAnalyzer is a plugin that hooks into that pipeline. You subscribe to a kind of syntax node, and the compiler calls you back for each one during every build. If something&#39;s off, you report a Diagnostic, which surfaces exactly like a built-in compiler warning: in the build output, in the IDE&#39;s error list, and as a live squiggle under the offending code as you type.</p><p>That last part is what makes it different in kind from a test. A failing test tells a developer they were wrong several minutes ago, after a context switch. An in-line warning tells them while their hand is still on the keyboard and the reasoning is still loaded in their head. The feedback arrives at the moment the decision is being made.</p><p>Crucially, this is the same mechanism analyzers from packages like Entity Framework already use. There’s no new tool to install and nothing for a developer to opt into.</p><h3>Encoding the Rule</h3><p>In our sample scenario, the analyzer’s job is to guard the escape hatch. For every method:</p><ol><li>Is it guarded by [BusinessAuthorize]? If not, ignore it.</li><li>Does it set CheckAgainstBusinessInRequest = false? Leaving the property alone means the check is on.</li><li>Does any parameter’s type expose a public BusinessId property?</li><li>If one does, the request names a business the check will never validate. Report a diagnostic.</li></ol><pre>[DiagnosticAnalyzer(LanguageNames.CSharp)]<br>public class BusinessAuthorizeAnalyzer : DiagnosticAnalyzer<br>{<br>    private static readonly DiagnosticDescriptor Rule = new(<br>        id: &quot;ABC001&quot;,<br>        title: &quot;BusinessAuthorize opts out of validating the BusinessId in the request&quot;,<br>        messageFormat: &quot;Action &#39;{0}&#39; sets CheckAgainstBusinessInRequest = false but &quot; +<br>                       &quot;request &#39;{1}&#39; carries a BusinessId, so the caller&#39;s access &quot; +<br>                       &quot;to that business is never validated&quot;,<br>        category: &quot;Security&quot;,<br>        defaultSeverity: DiagnosticSeverity.Warning,<br>        isEnabledByDefault: true,<br>        description: &quot;CheckAgainstBusinessInRequest = false is only correct when the business scope is enforced &quot; +<br>                     &quot;somewhere else. If the request carries a BusinessId, the endpoint is vulnerable to cross-tenant access unless the handler filters by the caller&#39;s allowed businesses.&quot;);<br><br>    public override ImmutableArray&lt;DiagnosticDescriptor&gt; SupportedDiagnostics =&gt;<br>        ImmutableArray.Create(Rule);<br><br>    public override void Initialize(AnalysisContext context)<br>    {<br>        context.EnableConcurrentExecution();<br>        context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);<br>        context.RegisterSyntaxNodeAction(AnalyzeMethod, SyntaxKind.MethodDeclaration);<br>    }<br><br>    private static void AnalyzeMethod(SyntaxNodeAnalysisContext context)<br>    {<br>        var method = (MethodDeclarationSyntax)context.Node;<br><br>        // 1. Guarded by [BusinessAuthorize]?<br>        var attribute = FindBusinessAuthorize(method);<br>        if (attribute is null) return;<br><br>        // 2. Untouched or explicitly true: the check is on, nothing to police.<br>        if (!OptsOutOfBusinessCheck(attribute)) return;<br><br>        // 3. Does any parameter&#39;s type expose a public BusinessId?<br>        var requestType = FindBusinessScopedParameterType(context, method);<br>        if (requestType is null) return;   // no business in the request: nothing to scope<br><br>        // 4. Opted out while the request names a business: warn.<br>        context.ReportDiagnostic(Diagnostic.Create(<br>            Rule, attribute.GetLocation(),<br>            method.Identifier.Text, requestType.Name));<br>    }<br>}</pre><p>Notice how much of the design is about <em>not</em> firing.</p><p>Two decisions do that work. OptsOutOfBusinessCheck returns true only for a literal false assignment. The request parameter is found by <em>shape</em>, not by name: any parameter whose type exposes a public BusinessId property is the request, however the type is named.</p><p>Step 3 is what keeps the rule off the endpoints that opt out for a mundane reason. An action like DeleteInvoice(string id) has no business ID anywhere in its request, so there is nothing to scope against and nothing to warn about, whatever the attribute says.</p><p>The result is a rule that fires on exactly one situation: <em>an endpoint that disabled the business check while its request carries a business ID.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FV8YTzipqM19f9n-.png" /></figure><h3>Wiring It Into Every Build</h3><p>This is the part that costs almost nothing and delivers the entire benefit. One reference in the project’s .csproj, with OutputItemType=&quot;Analyzer&quot; telling the build to load it as an analyzer rather than link it as a normal dependency:</p><pre>&lt;ItemGroup&gt;<br>  &lt;ProjectReference Include=&quot;..\MyApp.Analyzers\MyApp.Analyzers.csproj&quot;<br>                    OutputItemType=&quot;Analyzer&quot;<br>                    ReferenceOutputAssembly=&quot;false&quot; /&gt;<br>&lt;/ItemGroup&gt;</pre><p>The analyzer project itself targets netstandard2.0, which is required because analyzers load into the compiler host process, whether that host is dotnet build, Visual Studio, or Rider.</p><p>That’s the whole installation. From that commit onward, the check runs on every dotnet build, in every IDE, on every developer&#39;s machine, for anyone who clones the repository. A rule that lived in someone&#39;s head is now part of what the compiler does. A new joiner gets the rule enforced on their first build, before they have any idea the rule exists. Nobody has to be told and nobody has to remember.</p><h3>Making the Legitimate Opt-Outs Earn Their Place</h3><p>The endpoints that genuinely need to opt out can suppress the diagnostic, and say why:</p><pre>[SuppressMessage(&quot;Security&quot;, &quot;ABC001&quot;,<br>    Justification = &quot;Cross-business report; handler filters by the caller&#39;s allowed businesses&quot;)]</pre><p>With this, the opt-out becomes a written claim, sitting directly above the code, naming the alternative control that makes it safe.</p><p>A reviewer no longer has to notice a missing check, which is hard, and instead evaluates a stated argument, which is easy. It also gives you an audit trail for free: searching for ABC001 lists every deliberate exception in the codebase, each with its reasoning attached.</p><h3>Warning Today, Error Tomorrow</h3><p>The severity choice is the part that makes this humane to adopt on an existing codebase.</p><p>First, the analyzer can ship at <strong>Warning</strong> level only. Every existing violation lights up immediately, everywhere, but the build succeeds. The team works through them deliberately: remove the ones that shouldn&#39;t be there, suppress the legitimate ones with a justification.</p><p>Once every remaining ABC001 warning is either fixed or justified, the rule can be changed to an . This needs no change to the analyzer, only one line in .editorconfig:</p><pre>dotnet_diagnostic.ABC001.severity = error</pre><p>Warning and error are the same rule at different points in the codebase. That single line is what turns it from advice into a property of the build. After it lands, a rule violation is not a code smell, but a build failure, and nobody can skip it.</p><h3>Conclusion</h3><p>Every team has a handful of rules the programming language doesn’t know: like the type that money has to go through, the factory that entities have to be built with, the base class every handler has to inherit. Writing an analyzer for one of them is a few hours work, and it moves the rule to the compiler so that nobody can forget it.</p><p><em>Originally published at </em><a href="https://pabasara-mahindapala.github.io/dotnet/security/authorization/aspnetcore/2026/08/16/enforcing-tenant-isolation-with-a-roslyn-analyzer/"><em>https://pabasara-mahindapala.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a10627874f5b" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/business-rules-dont-have-to-live-in-a-wiki-page-enforcing-them-with-a-roslyn-analyzer-a10627874f5b">Business Rules Don’t Have to Live in a Wiki Page: Enforcing Them with a Roslyn Analyzer</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PKCE Won’t Save You: How the Upcoming MCP Auth Spec Tightens Up]]></title>
            <link>https://towardsdev.com/pkce-wont-save-you-how-the-upcoming-mcp-auth-spec-tightens-up-3d5608fd0ead?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d5608fd0ead</guid>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[mcp-client]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Sun, 12 Jul 2026 09:41:00 GMT</pubDate>
            <atom:updated>2026-08-31T13:32:01.705Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yC6bOEbllI3sOMlk.jpg" /></figure><p><em>What’s changing in the 2026–07–28 MCP authorization spec release and what you should do</em></p><p><strong>TL;DR:</strong> The next version of the MCP authorization spec brings six changes: all hardening and interoperability fixes, no redesigns. If you build MCP clients: validate iss, store credentials per issuer, declare your application_type, and combine your scopes on step-up.</p><p>The Model Context Protocol (MCP) has become the standard way for AI applications to connect to external tools and data. It lets an AI assistant plug into your backend, your company’s systems, or a coding tool. But every one of those connections raises the same question: how does the tool know the AI is allowed in, and acting on behalf of the right person?</p><p>That’s the job of <strong>MCP authorization</strong>, a specification built on OAuth 2.1, the same framework that handles countless enterprise logins. The current spec version, 2025–11–25, laid down a solid foundation. The upcoming version, <strong>2026–07–28</strong>, refines it. The release candidate is available, with final publication targeted for July 28th.</p><p>None of the six changes redesigns anything. They are hardening and interoperability fixes, and they all trace back to a single structural fact about MCP that’s worth understanding first.</p><h3>The Problem Underneath All Six Changes</h3><p>In a traditional app, the relationships are known in advance. Your banking app talks to your bank’s servers, which trust your bank’s login system. Everything was laid on the table ahead of time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7e9a6lwFpjzcgKLv.png" /></figure><p>MCP breaks that assumption. An MCP client might connect to dozens of MCP servers built by different people. Each of them is protected by a different authorization server the client has never encountered before. It could be an enterprise identity provider like <a href="https://wso2.com/identity-platform/identity-server/">WSO2 Identity Server</a>, a SaaS provider like <a href="https://asgardeo.io/signup/">WSO2 Identity Platform</a>, or a custom OAuth server they built themselves.</p><p><em>The client connects to MCP servers, discovers which server authorizes them, registers itself, and obtains credentials — all happening dynamically.</em></p><p>This <strong>“one client, many unknown authorities”</strong> dynamic is powerful, but it stretches OAuth in ways typical deployments never do. Each of the six changes in this release candidate patches a specific place where that stretch showed.</p><h3>1. Verifying the Issuer</h3><p><strong>The change:</strong> Clients must validate the iss (issuer) parameter on authorization responses, as defined in RFC 9207.</p><p>When you knock on a door and someone answers, you’d like to confirm they actually live there. Because an MCP client deals with many authorization servers, a malicious one could trick the client into handing over a login code meant for an honest server. This is known as a <strong>mix-up attack</strong>.</p><p>To avoid this, before starting the login flow, the client notes exactly which authorization server it intends to talk to. When the response comes back carrying an iss label, the client checks that the label matches its note. If it doesn&#39;t, the client rejects the response and the login fails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*54z26MzJ4EGmhvT5.png" /></figure><p>This is notable because PKCE, the protection most people assume covers this, does not stop mix-up attacks. The client sends its code verifier to whichever token endpoint it was tricked into using. (Read more on how PKCE is involved in MCP auth here: <a href="https://medium.com/towardsdev/mcp-server-authentication-in-net-implement-oauth-2-1-with-pkce-natively-5b5caae76e67?sharedUserId=pabasaramahindapala">MCP Server Authentication in .NET</a>.)</p><p>Today, authorization servers SHOULD emit iss - and must advertise it via authorization_response_iss_parameter_supported if they do. The spec signals that a future revision is expected to upgrade that to a MUST, so operators are encouraged to start emitting it now.</p><h3>2. Credentials That Don’t Transfer Between Authorities</h3><p><strong>The change:</strong> Client credentials must be bound to the specific authorization server that issued them, keyed by its issuer identifier.</p><p>A gym membership card works just at your gym, not at every gym. If an MCP server changes which authorization server protects it (which can happen when a company migrates identity providers), the client must not keep flashing its old credentials at the new provider. It has to register afresh with the new authority.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KM3KARpei_U_pRym.png" /></figure><p>This applies to pre-registered credentials and those obtained via Dynamic Client Registration (DCR). Interestingly, it doesn’t apply to <a href="https://datatracker.ietf.org/doc/draft-ietf-oauth-client-id-metadata-document/"><strong>Client ID Metadata Documents (CIMD)</strong></a>, which is MCP’s recommended registration mechanism, where the client ID is a self-hosted HTTPS URL that any authorization server can resolve on demand. CIMD identities are portable by construction, which quietly strengthens the case for using them.</p><h3>3. Telling the Server What Kind of App You Are</h3><p><strong>The change:</strong> Clients must declare an OpenID Connect (OIDC) application_type when registering dynamically.</p><p>Apps can come in two flavors: web apps that live on a server somewhere, and “native” apps that run on localhost: desktop tools, mobile apps, CLIs. These two flavors receive login redirects differently. If a desktop app doesn’t mention the type, many identity providers assume “web” by default and then reject the app’s legitimate localhost redirect address. The result, until now, was a confusing registration failure. Declaring the type up front fixes this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jc5kwxPLYjlLf561.png" /></figure><p>Omitting application_type defaults to &quot;web&quot; under OIDC Dynamic Client Registration, which conflicts with localhost redirect URIs. Native-style clients now register with application_type: &quot;native&quot;. Servers that don&#39;t implement OIDC can ignore the parameter, so the change is backward-compatible.</p><h3>4. Clearer Rules for Token Refresh</h3><p><strong>The change:</strong> The spec now documents how to request refresh tokens from OIDC-style authorization servers.</p><p>A refresh token is what lets an app stay connected without asking you to log in every hour. Different identity providers handle this differently: some issue them automatically, others only provide them if you explicitly ask using an offline_access scope. Earlier MCP clients had no guidance on navigating this split, leading to inconsistent behavior.</p><p>Now clients should include refresh_token in their registered grant types, and they may add offline_access to the scope when the authorization server advertises it. The client must never assume a refresh token will always be issued. Resource servers shouldn&#39;t advertise offline_access as a required scope, since staying signed in is a client concern, not a resource requirement.</p><h3>5. Asking for More Scopes Without Losing What You Had</h3><p><strong>The change:</strong> The spec clarifies how scopes accumulate when a client needs to “step up” its access.</p><p>Imagine you have a library card that lets you borrow books, and one day you need access to the archive room. When you go back to the desk to ask, you’d want your new pass to cover <em>both</em> the archive <em>and</em> your existing borrowing rights, not swap one for the other.</p><p><strong>The clarified rule:</strong> the server tells the client only what the current operation needs, and the <em>client</em> is responsible for combining that with everything it was already granted before re-requesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7nmMlSqScsj15eiu.png" /></figure><p>This keeps servers stateless. They emit per-operation insufficient_scope challenges without tracking each client&#39;s history, while clients compute the union of previously requested and newly challenged scopes. Servers are also urged to emit all missing scopes for an operation in a single challenge rather than one at a time, so clients can re-request them all at once.</p><h3>6. One Place to Look Up the Authorization Server</h3><p><strong>The change:</strong> The spec pins down exactly how clients discover an authorization server’s configuration.</p><p>Before the two systems can work together, one has to look up the other’s details: where to redirect logins, what options are supported. That lookup happens at the standardized “well-known” web addresses. But there were multiple conventions for constructing them, and ambiguity meant lookups could fail between perfectly good implementations. The spec now states the exact URL to use, and the order of precedence if multiple are present.</p><p>Now MCP uses the default oauth-authorization-server well-known suffix from <a href="https://datatracker.ietf.org/doc/html/rfc8414">RFC 8414</a> (there&#39;s no MCP-specific suffix). It defines a priority order across OAuth and OIDC discovery endpoints for issuers with and without path components. There&#39;s also a sharpened validation rule: the issuer value inside a fetched metadata document must exactly match the URL it was derived from, or the client must reject it.</p><h3>Key Takeaways</h3><p>When read together, the six changes tell one story: MCP’s authorization layer is being tuned to match how OAuth and OIDC are <em>actually deployed</em>. This can mean identity providers that default apps to “web”, servers that guard refresh tokens behind offline_access, or infrastructures that migrate authorization servers mid-flight. There are fewer grand redesigns, but more precise answers to questions raised in real deployments.</p><p>If you build MCP clients, the checklist is: <strong>validate </strong><strong>iss, store credentials per issuer, declare your </strong><strong>application_type, and combine your scopes on step-up.</strong> If you operate an authorization server, start emitting iss and advertising support for it now. The spec has signaled where things are headed, and you need to align with it.</p><blockquote><strong><em>Note</em></strong><em>: 2026–07–28 is a release candidate until its final publication date, so details may still shift. For the authoritative text, see the </em><a href="https://modelcontextprotocol.io/specification/draft/basic/authorization"><em>draft authorization specification</em></a><em> and the accompanying changelog.</em></blockquote><h3>Conclusion</h3><p>MCP’s authorization spec is settling into the work of matching real-world OAuth deployments, and that’s a good sign. If you’re building or securing an MCP integration, the checklist above should help you avoid the pitfalls and make your integrations more robust.</p><p><em>Originally published at </em><a href="https://pabasara-mahindapala.github.io/mcp/oauth/security/identity/2026/07/11/mcp-authorization-2026-07-28-changes/"><em>https://pabasara-mahindapala.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d5608fd0ead" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/pkce-wont-save-you-how-the-upcoming-mcp-auth-spec-tightens-up-3d5608fd0ead">PKCE Won’t Save You: How the Upcoming MCP Auth Spec Tightens Up</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sorting 70,000 Photos Without Losing the Weekend]]></title>
            <link>https://towardsdev.com/sorting-70-000-photos-without-losing-the-weekend-e2396c52d67c?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2396c52d67c</guid>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[privacy]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Sun, 31 May 2026 07:22:18 GMT</pubDate>
            <atom:updated>2026-07-30T11:00:40.966Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ysKVQqac4EyG7eDM.jpg" /></figure><h3>70,000 Images, No Clues</h3><p>Last week, I wanted to find a specific photo from six to seven years ago that my mom had sent me on WhatsApp.</p><p>I’m not using the same phone I had back then, but being a responsible digital hoarder, I had backed up the image galleries as I switched phones, and kept them archived.</p><p>You know how WhatsApp used to save every image you received to the gallery in older versions?</p><p>When I finally opened the archive, I was hit with over 70,000 images. Everything from selfies, memes, documents, screenshots to food pics were quietly accumulated over the years. I knew the image I wanted was definitely in there, but finding it was like looking for a needle in a haystack.</p><p>Not all of these images matter, plenty are forwarded memes, screenshots and other junk. But buried somewhere in that pile are photos I actually care about: old family photos, celebrations, moments and memories I’d genuinely miss if they were gone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/0*ZhbSHS794ESt9eqZ.png" /></figure><p>Sorting them manually was not possible at this point. Even at 5 seconds per image, that’s nearly 100 hours of work.</p><p>Here’s how I automated the sorting process with everything running locally on my machine, without uploading a single image to the cloud.</p><h3>CLIP</h3><p>The model I used is <strong>CLIP</strong> (Contrastive Language-Image Pretraining), developed by OpenAI. CLIP isn’t trained to generate images or describe them when pointed to one. It is trained to understand the relationship between images and given text. Feed it an image and a sentence, and it will tell you how much the image matches the description.</p><p>This makes it ideal for a classification task without any training. I defined 13 categories that were likely to be present in my archive: Chat Screenshots, Selfies, Person Photos, Memes, Food Photos, Nature Photos, Documents, Quotes, Charts and Infographics, Stickers and Illustrations, News Screenshots, Events and Celebrations, and Other.</p><p>Without labelled data or fine-tuning, CLIP could still categorise my images accurately. Here’s why:</p><h3>Why CLIP Fits This Problem</h3><p>Traditional image classifiers are usually trained on a fixed set of categories. You can’t add “Memes” or “Screenshots” without retraining on thousands of labelled examples of each. Which makes them useless for a categorisation task like this.</p><p>In contrast, CLIP was trained on 400 million image and text pairs grabbed from the internet, learning a shared embedding space where images and text can be directly compared as vectors. At classification time, it will encode your image and each category description into that space and pick whichever category is nearest. Since the categories are just sentences, changing or adding can be easily done by updating a single line of text, without retraining.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SsWfrLRXU44qFYZ0.png" /></figure><p>However, the quality of the descriptions directly affects accuracy. “Meme” as a label is vague, but “a humorous image with text overlaid on an image” gives the model something specific to match against. That’s why writing good descriptions as prompts for each category matters.</p><p>Another reason CLIP fits well here is its size. Vision LLMs capable of understanding image content in similar depth are usually 7–70 billion parameters (models like LLaVA or Qwen-VL) and would take hours to process 70,000 images on consumer hardware like a MacBook. CLIP’s ViT-L/14 is a pure encoder with no generative overhead, sized under 1GB, and processes images in large parallel batches. For a task like this that just needs a category label, it&#39;s the right tool.</p><h3>Running Locally, Entirely Private</h3><p>In the whole flow, each and every image stayed on my machine. I didn’t have to worry about uploading any sensitive information to the cloud.</p><p>The ViT-L/14 variant of CLIP weighs about 890MB and fits comfortably in memory. On my M1 MacBook Air with 16GB of unified RAM, it peaked at ~4GB, leaving the rest free. Apple&#39;s Metal GPU acceleration (MPS) helped the model run on the GPU without any special setup.</p><p>It was processing the 70,000 images in batches of 64, and the whole process took about three hours. Compared to the weeks of manual sorting effort that would have taken, it was very much worth it.</p><h3>Prompt Ensembling</h3><p>Since CLIP’s accuracy depends heavily on how you describe each category in text, rather than using a single label like “Meme”, I wrote four descriptive prompts per category and averaged their text embeddings:</p><pre>&quot;an internet meme with text overlay on an image&quot;<br>&quot;a funny meme image with a caption&quot;<br>&quot;a viral internet joke image with text&quot;<br>&quot;a humorous image macro with white text&quot;</pre><p>This technique is called <strong>prompt ensembling</strong> and it can squeeze 3–5% more accuracy out of the model. In this task, CLIP’s confidence scores also needed a temperature correction: applying the model’s learned logit_scale parameter sharpens the probability distributions, which without it are nearly flat across 13 categories.</p><p>Images where CLIP’s top confidence score fell below a threshold were sent to a _Review folder where they could be manually checked, without being silently miscategorised. In my image set, only about 1% ended up in _Review.</p><p>It should be noted that the accuracy gap is real, CLIP occasionally confuses a selfie for a person photo, or a chat screenshot for a document. But for a large archive where no sorting was going to happen otherwise, it was more than good enough. The tradeoff was obvious: 1% of images that landed in _Review can be sorted manually in minutes, not hours.</p><h3>What Surprised Me</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*k4rQQlIE2k70CSKO.png" /></figure><p>The category distribution was unexpected. Of the 70,000 images processed, <strong>56% were classified as Screenshots</strong>, far more than I expected. It’s a reminder of how much useless noise we accumulate in our digital lives. Only about 4600 images were worth keeping, and the rest were mostly junk.</p><p>Confidence scores were also remarkably polarised: the median confidence was 0.83, and the 90th percentile was 0.999. CLIP either knows what it’s looking at, or it admits it doesn’t. That binary quality made it a genuinely useful triage tool for a task like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/0*wySryaNUqfWXAHHt.png" /></figure><p>Once the images were sorted, I could easily scan through the short list of person photos and find the specific one I was looking for.</p><p>But more than that, the payoff goes beyond a single photo. Now I know things that are actually worth keeping. I can back those up properly, and delete the junk without being worried about losing anything important.</p><p>If you want to run this yourself, the full code is on GitHub:</p><p><a href="https://github.com/pabasara-mahindapala/zero-shot-image-classifier">GitHub - pabasara-mahindapala/zero-shot-image-classifier: Zero-shot local image classifier using CLIP ViT-L/14. Sort large image collections into custom categories</a></p><p>Thanks for reading! If you have any questions or want to share your own experiences with sorting large photo archives, feel free to reach out.</p><p><em>Originally published at </em><a href="https://pabasara-mahindapala.github.io/machine-learning/python/productivity/image-classification/2026/05/31/sorting-70000-photos-with-clip"><em>https://pabasara-mahindapala.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2396c52d67c" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/sorting-70-000-photos-without-losing-the-weekend-e2396c52d67c">Sorting 70,000 Photos Without Losing the Weekend</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Your Local MCP Server with Claude Desktop and Claude Code]]></title>
            <link>https://towardsdev.com/testing-your-local-mcp-server-with-claude-desktop-and-claude-code-9afef3c76fb4?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/9afef3c76fb4</guid>
            <category><![CDATA[https]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Tue, 05 May 2026 12:36:01 GMT</pubDate>
            <atom:updated>2026-05-19T08:13:13.748Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZrQfUwAUZjyBPOAC" /><figcaption>Photo by <a href="https://unsplash.com/@almoya?utm_source=medium&amp;utm_medium=referral">Aerps.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You’ve built an MCP server and it’s running on https://localhost:5000. Now you want to test it with a real client. How do you connect it to Claude Desktop or Claude Code?</p><h3>Claude Desktop</h3><p>Claude Desktop only supports connecting to MCP servers over <strong>STDIO</strong>: it can write to a local process’s stdin and read from stdout. But your MCP server speaks HTTP, so you will need a proxy in the middle.</p><p><a href="https://www.npmjs.com/package/mcp-remote">mcp-remote</a> acts as that proxy:</p><blockquote>Claude Desktop → (STDIO) → mcp-remote → (HTTPS) → localhost:5000/mcp</blockquote><p>It’s a small Node.js process that Claude Desktop can launch locally. On this side it speaks STDIO; on the other it makes HTTP requests to your server.</p><p>It also has OAuth authentication integrated, adds a local callback endpoint, opens the browser for you to log in, and caches the token so subsequent restarts don’t prompt again.</p><h3>Configuration</h3><p>Open %APPDATA%\Claude\claude_desktop_config.json (Windows) or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) and add your server, with npx mcp-remote as the command and the URL as an argument. Here, you can set the --transport flag to http-only if your server doesn&#39;t communicate via (Server Sent Events) SSE.</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;MyApp&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;mcp-remote&quot;,<br>        &quot;https://localhost:5000/mcp&quot;,<br>        &quot;--transport&quot;,<br>        &quot;http-only&quot;<br>      ],<br>      &quot;env&quot;: {<br>        &quot;NODE_TLS_REJECT_UNAUTHORIZED&quot;: &quot;0&quot;<br>      }<br>    }<br>  }<br>}</pre><p>The NODE_TLS_REJECT_UNAUTHORIZED=0 flag will be needed for a local development server with a self-signed certificate. Node.js (which mcp-remote runs on) rejects self-signed certs by default, and this will ask it to skip the TLS verification.</p><p>The flag lives in mcp-remote&#39;s env block because mcp-remote is the one making the HTTPS request. Note that Claude Desktop itself never connects directly to your server.</p><p>Restart Claude Desktop after saving. On first launch a browser window should open for OAuth login.</p><h3>Claude Code</h3><p>Claude Code understands HTTP transport natively, so no proxy is needed in this case. You can register your local server with one command:</p><pre>claude mcp add --transport http MyApp https://localhost:5000/mcp</pre><p>Or add it to your project’s .claude/settings.json:</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;MyApp&quot;: {<br>      &quot;type&quot;: &quot;http&quot;,<br>      &quot;url&quot;: &quot;https://localhost:5000/mcp&quot;<br>    }<br>  }<br>}</pre><p>Claude Code handles the OAuth flow the same way. The browser opens on first use, you authenticate, the token is cached, and subsequent runs are silent. There is no proxy process or STDIO bridge required.</p><h3>Self-signed certificate workaround</h3><p>Unlike Claude Desktop’s command-based entries, HTTP-type MCP entries in .claude/settings.json don&#39;t have an env block, so you can&#39;t scope the TLS flag to a single server. Instead, set it in the global ~/.claude/settings.json:</p><pre>{<br>  &quot;env&quot;: {<br>    &quot;NODE_TLS_REJECT_UNAUTHORIZED&quot;: &quot;0&quot;<br>  }<br>}</pre><p>This sets the flag for the entire Claude Code process rather than for one MCP connection specifically. The same caveat applies: This should be restricted to development only, and you should remove it afterwards.</p><p>That’s it! With these configurations, you should be able to test your local MCP server with both Claude Desktop and Claude Code.</p><p><em>Originally published at </em><a href="https://pabasara-mahindapala.github.io/software-development/2026/05/03/connecting-mcp-server-claude-desktop-claude-code/"><em>https://pabasara-mahindapala.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9afef3c76fb4" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/testing-your-local-mcp-server-with-claude-desktop-and-claude-code-9afef3c76fb4">Testing Your Local MCP Server with Claude Desktop and Claude Code</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MCP Server Authentication in .NET: Implement OAuth 2.1 with PKCE Natively]]></title>
            <link>https://towardsdev.com/mcp-server-authentication-in-net-implement-oauth-2-1-with-pkce-natively-5b5caae76e67?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b5caae76e67</guid>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Sun, 03 May 2026 05:57:43 GMT</pubDate>
            <atom:updated>2026-05-19T08:13:16.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_nexe9a6PcE5SnOg" /><figcaption>Photo by <a href="https://unsplash.com/@flyd2069?utm_source=medium&amp;utm_medium=referral">FlyD</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>TL;DR:</strong> The Model Context Protocol (MCP) specification mandates using OAuth 2.1 with PKCE for server authentication.</p><p>This article walks through implementing this authentication layer natively in ASP.NET Core, including authorization server, dynamic client registration, PKCE verification, and token issuance.</p><h3>MCP Server Authentication</h3><p>The Model Context Protocol (MCP) allows building MCP servers that expose your backend as a set of tools to MCP clients.</p><p>The <a href="https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization">MCP specification</a> addresses how the authorization layer should be implemented. Remote MCP servers <strong>must</strong> use OAuth 2.1 to protect their endpoints.</p><p>For large scale systems, the strategy is usually using a managed Identity Provider (IdP) like <a href="https://wso2.com/asgardeo/">Asgardeo</a>. It handles the authorization server, dynamic client registration, token management, and refresh token handling OOTB. You can configure your application as a resource server, point the WWW-Authenticate header at Asgardeo&#39;s discovery endpoint, and you&#39;re done.</p><p>But not every project will need that overhead. For a smaller app where adding a SaaS/On-Prem IdP is hard, you can implement the OAuth 2.1 layer yourself. The specification is clear enough that a well-scoped native implementation is straightforward.</p><p>This article walks through building the authentication for an MCP server in ASP.NET Core natively.</p><p>Here is the complete flow we’ll implement:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s2z2LDq354yYRIx7.png" /></figure><h3>Overview of the Requirements</h3><p><strong>1. OAuth 2.1</strong> — Authorization code flow needs to be used.</p><p><strong>2. PKCE</strong> — Proof Key for Code Exchange (S256 method only). Prevents authorization code interception attacks.</p><p><strong>3. Dynamic Client Registration</strong> — MCP clients need to auto-register before starting the auth flow. MCP server must accept POST /oauth/register and return a client_id.</p><p><strong>4. Discovery endpoints</strong> — two well-known URLs that allow clients to find your authorization and token endpoints:</p><ul><li>GET /.well-known/oauth-protected-resource</li><li>GET /.well-known/oauth-authorization-server</li></ul><p><strong>5. A </strong><strong>WWW-Authenticate header</strong> - when a request arrives at the MCP endpoint without a valid token, the MCP server must respond with 401 status code and a header that points to the protected resource metadata URL.</p><p>Once a client has a valid Bearer token, every subsequent request to /mcp must carry it in the Authorization header. Your API validates it the same way it validates any JWT.</p><h3>Initial Setup</h3><p>The MCP SDK for .NET (<a href="https://www.nuget.org/packages/ModelContextProtocol.AspNetCore">ModelContextProtocol.AspNetCore</a>) handles the protocol transport. Here, the authentication is handled using the standard ASP.NET Core JWT Bearer middleware.</p><pre>// Program.cs<br>builder.Services.AddMcpServer()<br>    .WithHttpTransport(o =&gt; o.Stateless = true)<br>    .WithToolsFromAssembly();<br><br>builder.Services.Configure&lt;OAuthOptions&gt;(<br>    builder.Configuration.GetSection(OAuthOptions.Section));<br>builder.Services.AddSingleton&lt;AuthorizationCodeStore&gt;();</pre><p>WithToolsFromAssembly() discovers all classes decorated with [McpServerToolType] and registers their methods automatically as MCP tools. Stateless = true tells the transport layer not to maintain session state between requests. Here, each call is self-contained, which is the norm for API endpoints.</p><pre>app.MapMcp(&quot;/mcp&quot;).RequireAuthorization(&quot;McpAccess&quot;);</pre><p>Here our /mcp endpoint uses a named policy rather than bare .RequireAuthorization(). Without this, any valid JWT issued by this server (including unrelated app sessions) could call the MCP tools. The policy to restrict access is defined in the authorization setup:</p><pre>services.AddAuthorization(options =&gt;<br>{<br>    options.AddPolicy(&quot;McpAccess&quot;, policy =&gt;<br>        policy.RequireAuthenticatedUser()<br>              .RequireClaim(&quot;scope&quot;, &quot;mcp:tools&quot;));<br>});</pre><p>RequireClaim(&quot;scope&quot;, &quot;mcp:tools&quot;) ensures only tokens issued through the MCP OAuth flow pass. Tokens from normal login flows do not carry this claim, and they&#39;re rejected at the MCP endpoint even if they&#39;re otherwise valid.</p><h3>401 Challenge and Exposing well-known URLs</h3><p>When a client hits /mcp without a token, in addition to the default JWT Bearer 401 response, the MCP spec requires the WWW-Authenticate response header to include a resource_metadata URL. MCP clients use this URL to discover the authorization server and start the OAuth flow.</p><p>We use the JWT Bearer OnChallenge event to add it:</p><pre>builder.Services.PostConfigure&lt;JwtBearerOptions&gt;(<br>    JwtBearerDefaults.AuthenticationScheme, options =&gt;<br>{<br>    options.Events ??= new JwtBearerEvents();<br>    options.Events.OnChallenge = async context =&gt;<br>    {<br>        if (!context.HttpContext.Request.Path.StartsWithSegments(&quot;/mcp&quot;))<br>        {<br>            // Let the default challenge handler run for non-MCP endpoints.<br>            return;<br>        }<br><br>        context.HandleResponse();<br>        context.Response.StatusCode = StatusCodes.Status401Unauthorized;<br><br>        var issuer = $&quot;{context.Request.Scheme}://{context.Request.Host}&quot;;<br>        var resourceMetadata = $&quot;{issuer}/.well-known/oauth-protected-resource&quot;;<br><br>        context.Response.Headers[&quot;WWW-Authenticate&quot;] =<br>            $&quot;Bearer realm=\&quot;mcp\&quot;, resource_metadata=\&quot;{resourceMetadata}\&quot;&quot;;<br>    };<br>});</pre><p>context.HandleResponse() will suppress the default 401 body and let you write your own. The resource_metadata value is the URL that the client will fetch next.</p><h3>Exposing Discovery Endpoints</h3><p>The client follows the resource_metadata URL to learn about our authorization server. Two endpoints are required:</p><pre>[ApiController]<br>[AllowAnonymous]<br>[Route(&quot;.well-known&quot;)]<br>public class WellKnownController : ControllerBase<br>{<br>    [HttpGet(&quot;oauth-protected-resource&quot;)]<br>    public IActionResult GetProtectedResourceMetadata()<br>    {<br>        var issuer = GetIssuer();<br>        return Ok(new Dictionary&lt;string, object&gt;<br>        {<br>            [&quot;resource&quot;] = $&quot;{issuer}/mcp&quot;,<br>            [&quot;authorization_servers&quot;] = new[] { issuer },<br>            [&quot;scopes_supported&quot;] = new[] { &quot;mcp:tools&quot; }<br>        });<br>    }<br><br>    [HttpGet(&quot;oauth-authorization-server&quot;)]<br>    public IActionResult GetAuthorizationServerMetadata()<br>    {<br>        var issuer = GetIssuer();<br>        return Ok(new Dictionary&lt;string, object&gt;<br>        {<br>            [&quot;issuer&quot;] = issuer,<br>            [&quot;authorization_endpoint&quot;] = $&quot;{issuer}/oauth/authorize&quot;,<br>            [&quot;token_endpoint&quot;] = $&quot;{issuer}/oauth/token&quot;,<br>            [&quot;registration_endpoint&quot;] = $&quot;{issuer}/oauth/register&quot;,<br>            [&quot;response_types_supported&quot;] = new[] { &quot;code&quot; },<br>            [&quot;grant_types_supported&quot;] = new[] { &quot;authorization_code&quot;, &quot;refresh_token&quot; },<br>            [&quot;token_endpoint_auth_methods_supported&quot;] = new[] { &quot;none&quot; },<br>            [&quot;code_challenge_methods_supported&quot;] = new[] { &quot;S256&quot; }<br>        });<br>    }<br><br>    private string GetIssuer() =&gt;<br>        $&quot;{Request.Scheme}://{Request.Host}{Request.PathBase}&quot;.TrimEnd(&#39;/&#39;);<br>}</pre><p>This authorization_servers array in the protected resource response says to the client which authorization server endpoints it should use for authentication.</p><h3>Dynamic Client Registration (DCR)</h3><p>Since MCP clients don’t have pre-configured client_id values, they need to register themselves as clients the first time they connect. The POST /oauth/register endpoint accepts the request and returns a new client_id that they can use.</p><pre>[HttpPost(&quot;register&quot;)]<br>public async Task&lt;IActionResult&gt; Register()<br>{<br>    string[]? redirectUris = null;<br><br>    if (Request.ContentType?.Contains(&quot;application/json&quot;) == true)<br>    {<br>        using var doc = await JsonDocument.ParseAsync(Request.Body);<br>        if (doc.RootElement.TryGetProperty(&quot;redirect_uris&quot;, out var urisEl)<br>            &amp;&amp; urisEl.ValueKind == JsonValueKind.Array)<br>        {<br>            redirectUris = urisEl.EnumerateArray()<br>                .Select(u =&gt; u.GetString() ?? string.Empty)<br>                .Where(u =&gt; !string.IsNullOrEmpty(u))<br>                .ToArray();<br>        }<br>    }<br><br>    var clientId = _authorizationCodeStore.RegisterClient();<br><br>    return Ok(new Dictionary&lt;string, object&gt;<br>    {<br>        [&quot;client_id&quot;] = clientId,<br>        [&quot;client_id_issued_at&quot;] = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),<br>        [&quot;token_endpoint_auth_method&quot;] = &quot;none&quot;,<br>        [&quot;grant_types&quot;] = new[] { &quot;authorization_code&quot;, &quot;refresh_token&quot; },<br>        [&quot;response_types&quot;] = new[] { &quot;code&quot; },<br>        [&quot;redirect_uris&quot;] = redirectUris ?? Array.Empty&lt;string&gt;()<br>    });<br>}</pre><p>The client_id is a random Base64Url string that identifies a client using the authorization server. Note that we keep this in memory and don&#39;t persist it anywhere.</p><h3>Authorization Code Flow (with PKCE)</h3><p>Authorization code flow with PKCE is required to be used by the MCP specification. This flow will have three steps.</p><ol><li>Render the login form</li><li>Handle the credential submission and issue an authorization code</li><li>Exchange the code for tokens</li></ol><h3>Step 1 — Render the Login Form</h3><pre>[HttpGet(&quot;authorize&quot;)]<br>public IActionResult Authorize(<br>    [FromQuery(Name = &quot;client_id&quot;)] string clientId,<br>    [FromQuery(Name = &quot;redirect_uri&quot;)] string redirectUri,<br>    [FromQuery(Name = &quot;response_type&quot;)] string responseType,<br>    [FromQuery(Name = &quot;code_challenge&quot;)] string codeChallenge,<br>    [FromQuery(Name = &quot;code_challenge_method&quot;)] string codeChallengeMethod,<br>    [FromQuery] string state,<br>    [FromQuery] string? scope)<br>{<br>    var request = new OAuthAuthorizeRequest(<br>        clientId, redirectUri, responseType,<br>        codeChallenge, codeChallengeMethod, state, scope);<br><br>    if (!TryValidateAuthorizeRequest(request, out var validationError))<br>        return BadRequest(validationError);<br><br>    return RenderLoginForm(request);<br>}</pre><p>Several validation checks:</p><ol><li>Valid client_id (dynamically registered)</li><li>response_type=code</li><li>code_challenge_method=S256</li><li>An allowed redirect_uri</li></ol><p>If any of the validations fail, the server must return a 400 error response with an appropriate error message.</p><h3>Step 2 — Handle Credentials and Issue an Authorization Code</h3><pre>[HttpPost(&quot;authorize&quot;)]<br>public async Task&lt;IActionResult&gt; Authorize([FromForm] OAuthLoginForm form)<br>{<br>    var request = form.ToAuthorizeRequest();<br><br>    if (!TryValidateAuthorizeRequest(request, out var validationError))<br>        return BadRequest(validationError);<br><br>    var loginResult = await _authenticationService.Login(new LoginCommand<br>    {<br>        Email = form.Email,<br>        Password = form.Password,<br>        RememberMe = false<br>    });<br><br>    if (loginResult.IsError)<br>        return RenderLoginForm(request, GetLoginErrorMessage(loginResult));<br><br>    var user = await _userManager.FindByIdAsync(loginResult.Payload.UserId);<br><br>    var code = _authorizationCodeStore.Create(<br>        user.Id, request.ClientId, request.RedirectUri, request.CodeChallenge);<br><br>    var redirectUrl = BuildRedirectUrl(request.RedirectUri, code, request.State);<br>    return Redirect(redirectUrl);<br>}</pre><p>Here, the _authenticationService can be any existing login service you have in your application. The key part is that on successful login, it generates a one-time authorization code and store it in memory along with the code_challenge. The state parameter is passed back to the client as is.</p><h3>Step 3 — Exchange the Code for Tokens</h3><pre>private async Task&lt;IActionResult&gt; ExchangeAuthorizationCode(IFormCollection form)<br>{<br>    var code = form[&quot;code&quot;].ToString();<br>    var clientId = form[&quot;client_id&quot;].ToString();<br>    var redirectUri = form[&quot;redirect_uri&quot;].ToString();<br>    var codeVerifier = form[&quot;code_verifier&quot;].ToString();<br><br>    if (!_authorizationCodeStore.TryConsume(code, out var entry))<br>        return OAuthError(&quot;invalid_grant&quot;,<br>            &quot;Authorization code is invalid or expired.&quot;, HttpStatusCode.BadRequest);<br><br>    if (entry.ClientId != clientId || entry.RedirectUri != redirectUri)<br>        return OAuthError(&quot;invalid_grant&quot;,<br>            &quot;Authorization code does not match the request.&quot;, HttpStatusCode.BadRequest);<br><br>    if (!VerifyPkce(codeVerifier, entry.CodeChallenge))<br>        return OAuthError(&quot;invalid_grant&quot;,<br>            &quot;PKCE verification failed.&quot;, HttpStatusCode.BadRequest);<br><br>    var user = await _userManager.FindByIdAsync(entry.UserId);<br>    var (accessToken, refreshToken) = await _authenticationService<br>        .GenerateAccessAndRefreshTokens(user, scope: &quot;mcp:tools&quot;);<br><br>    return Ok(BuildTokenResponse(accessToken, refreshToken));<br>}</pre><p>Again, your existing token generation logic can be reused here (Eg: Asp.NET Core Identity with JWT).</p><p>Here, TryConsume will remove the code from the store atomically, since authorization codes are single-use only. Then we run three checks in order:</p><ol><li>Verify the code belongs to the requesting client</li><li>Verify the redirect URI matches</li><li>Verify the PKCE verifier hashes to the stored challenge</li></ol><pre>private static bool VerifyPkce(string codeVerifier, string expectedChallenge)<br>{<br>    var challenge = WebEncoders.Base64UrlEncode(<br>        SHA256.HashData(Encoding.ASCII.GetBytes(codeVerifier)));<br><br>    return string.Equals(challenge, expectedChallenge, StringComparison.Ordinal);<br>}</pre><p>PKCE makes this flow secure against interception attacks. Even if an attacker captures the authorization code, they cannot exchange it for tokens without the original code_verifier value, which only the legitimate client will have.</p><h3>Authorization Code Store</h3><p>As mentioned earlier, we use an in-memory store to handle code creation, consumption, and client registration. However, as per project requirements, this can be swapped out for a persistent store without much change to the overall logic.</p><p>If you need persistence across restarts, the store can be moved to a database table while the interface stays the same. Swap ConcurrentDictionary for EF Core tables, add an index on the code column, and a background cleanup job can be added for expired entries.</p><p>Code and client lifetimes can be set as needed:</p><pre>public class AuthorizationCodeStore<br>{<br>    private static readonly TimeSpan CodeLifetime = TimeSpan.FromMinutes(2);<br>    private static readonly TimeSpan DynamicClientLifetime = TimeSpan.FromHours(24);<br><br>    private readonly ConcurrentDictionary&lt;string, AuthorizationCodeEntry&gt; _codes = new();<br>    private readonly ConcurrentDictionary&lt;string, DateTimeOffset&gt; _dynamicClients = new();<br><br>    public string Create(<br>        string userId, string clientId, string redirectUri, string codeChallenge)<br>    {<br>        PruneExpiredEntries();<br>        var code = GenerateCode();<br>        _codes[code] = new AuthorizationCodeEntry(<br>            userId, clientId, redirectUri, codeChallenge,<br>            DateTimeOffset.UtcNow.Add(CodeLifetime));<br>        return code;<br>    }<br><br>    public bool TryConsume(string code, out AuthorizationCodeEntry entry)<br>    {<br>        if (!_codes.TryRemove(code, out entry))<br>            return false;<br><br>        if (entry.ExpiresAtUtc &lt;= DateTimeOffset.UtcNow)<br>        {<br>            entry = default!;<br>            return false;<br>        }<br><br>        return true;<br>    }<br><br>    public string RegisterClient()<br>    {<br>        PruneExpiredDynamicClients();<br>        var clientId = GenerateCode();<br>        _dynamicClients[clientId] = DateTimeOffset.UtcNow.Add(DynamicClientLifetime);<br>        return clientId;<br>    }<br><br>    public bool IsDynamicClient(string clientId) =&gt;<br>        _dynamicClients.TryGetValue(clientId, out var expiry) &amp;&amp; expiry &gt; DateTimeOffset.UtcNow;<br><br>    private static string GenerateCode() =&gt;<br>        WebEncoders.Base64UrlEncode(RandomNumberGenerator.GetBytes(32));<br><br>    private void PruneExpiredEntries()<br>    {<br>        var now = DateTimeOffset.UtcNow;<br>        foreach (var pair in _codes)<br>            if (pair.Value.ExpiresAtUtc &lt;= now)<br>                _codes.TryRemove(pair.Key, out _);<br>    }<br><br>    private void PruneExpiredDynamicClients()<br>    {<br>        var now = DateTimeOffset.UtcNow;<br>        foreach (var pair in _dynamicClients)<br>            if (pair.Value &lt;= now)<br>                _dynamicClients.TryRemove(pair.Key, out _);<br>    }<br>}</pre><p>We use ConcurrentDictionary to make the store thread-safe without explicit locking. Also, TryRemove is atomic and it handles the race condition if two concurrent requests try to consume the same code.</p><h3>Defining the MCP Tools</h3><p>Now we have completed the authentication layer for the MCP server.</p><p>Defining the tools for your MCP is straightforward.</p><p>The SDK discovers them via [McpServerToolType] and [McpServerTool] added to your classes and methods.</p><p>For example:</p><pre>[McpServerToolType]<br>public static class ProductTools<br>{<br>    [McpServerTool, Description(&quot;List products with optional search and pagination.&quot;)]<br>    public static async Task&lt;ProductsResponse&gt; GetProducts(<br>        IMediator mediator,<br>        [Description(&quot;Optional free-text search.&quot;)] string? searchText = null,<br>        [Description(&quot;Page number for pagination.&quot;)] int pageNumber = 1,<br>        [Description(&quot;Number of rows per page.&quot;)] int rowsPerPage = 50)<br>    {<br>        return await mediator.Send(new GetProductsQuery<br>        {<br>            SearchText = searchText,<br>            PageNumber = pageNumber,<br>            RowsPerPage = rowsPerPage<br>        });<br>    }<br>}</pre><p>Dependencies like IMediator can be injected directly as method parameters, no constructor or controller needed. The SDK will resolve them from the DI container per request.</p><h3>When to Use This approach vs. a Managed IdP</h3><p>This implementation covers the MCP spec requirements and works well for a small to medium project with an existing user base and authentication system. It allows you to expose an MCP server without integrating a full Identity Provider, which can be overkill for simple use cases.</p><p>But in a larger system with multiple applications, shared user bases, or complex compliance requirements, a managed IdP can be the right choice. It already has the features you need, and it offloads the burden of securely implementing and maintaining the auth layer.</p><p>Check out <a href="https://wso2.com/asgardeo/">Asgardeo</a> or <a href="https://wso2.com/identity-platform/access-manager/">WSO2 Identity Server</a> if you want to follow that route. Both support the MCP spec and can be configured with minimal effort.</p><p><a href="https://is.docs.wso2.com/en/latest/guides/agentic-ai/mcp/mcp-server-authorization/">Securing MCP Servers - WSO2 Identity Server</a></p><h3>Wrapping Up</h3><p>Implementing MCP server authentication natively in ASP.NET Core with OAuth 2.1 and PKCE is not as complex as it looks once you break it into its components.</p><p>The spec is clear, and the existing .NET authentication features can integrate with the custom logic to handle the required flows.</p><p><em>Originally published at </em><a href="http://pabasara-mahindapala.github.io/dotnet/security/authentication/aspnetcore/2026/05/02/mcp-server-oauth2-dotnet"><em>https://pabasara-mahindapala.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b5caae76e67" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/mcp-server-authentication-in-net-implement-oauth-2-1-with-pkce-natively-5b5caae76e67">MCP Server Authentication in .NET: Implement OAuth 2.1 with PKCE Natively</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Residuality Method: Evolving an Identity System from Naive to Unbreakable]]></title>
            <link>https://towardsdev.com/the-residuality-method-evolving-an-identity-system-from-naive-to-unbreakable-533127590838?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/533127590838</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Tue, 14 Apr 2026 13:15:36 GMT</pubDate>
            <atom:updated>2026-05-19T08:12:48.517Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yFZZUsMRTLCTyl0Q" /><figcaption>Photo by <a href="https://unsplash.com/@leo_visions_?utm_source=medium&amp;utm_medium=referral">Leo_Visions</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a> (Cathédrale Notre-Dame de Paris — Built to last a thousand years)</figcaption></figure><p>When we design a piece of software, usually we focus on the functional requirements and often try to follow the happy path.</p><p>We create detailed diagrams that explain how data flows through the system, how different components work together, and how all requirements are met.</p><p>Yet, when these systems are tested against the real world, they often crumble. Long outages, unsatisfied users and business losses comes next, and the architecture that looked perfect on paper fails to survive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*weMtZp2qnLAPcAcK" /><figcaption>Photo by <a href="https://unsplash.com/@guerrillabuzz?utm_source=medium&amp;utm_medium=referral">GuerrillaBuzz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recently, I came across the <strong>Residuality Theory</strong>, an approach to software architecture that focuses on building systems that can survive chaos.</p><p>The residuality theory, created by <strong>Barry O’Reilly</strong>, is a way to design software architecture not based on predicted requirements, but on the “residue” that remains after the software is tested against random, chaotic events.</p><p>Instead of guessing what features we need, we apply different stressors to find the failure points and reinforce the structure to survive them. The result is an architecture that is capable of surviving unexpected challenges.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0wcUG2EV-7E%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0wcUG2EV-7E&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0wcUG2EV-7E%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/68ef515de2d5420dbea9e84cce8fbe19/href">https://medium.com/media/68ef515de2d5420dbea9e84cce8fbe19/href</a></iframe><p>Today I will focus on a specific example, building an Identity &amp; Access Management (IAM) software that can survive in the real world, following the Residuality Method.</p><h4>Start Naive</h4><p>First, we start with a naive architecture. This is the simplest possible design that meets all the functional requirements.</p><p>As the second step, we apply a random, chaotic event (a stressor) to the system. This could be a business event, a technical failure or a malicious attack from the outside.</p><p>Then we observe the failure points and reinforce just enough structure to survive that failure. The result is the residue, which becomes part of our final architecture.</p><p>Finally, we reiterate this process with different stressors, building a robust system that can survive a wide range of unexpected events.</p><h3>Building an IAM System</h3><p>Let’s apply this method to build an Identity and Access Management (IAM) system. We will start with a naive architecture and evolve it through multiple stressors that I have encountered in real-world IAM projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HmXW9Jls8dKwr8K-" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Naive IAM Architecture</h4><p>Our starting point is an monolithic IAM system. It consists of a API service connected to a User Database. It follows the standard Open ID Connect (OIDC) flow.</p><p>Applications use the API service to authenticate users with username and password, and exchange an authorization code for an access token and refresh token. The system keeps a few claims for the users stored in the database, and return the user’s permissions back to the application in the JWT token.</p><p>Simple, straightforward, and meets the functional requirements.</p><h4>Stressor 1: The IOPS Saturation (Database Volume)</h4><p>The first stressor we apply is the “IOPS Saturation.” Imagine that our user base grows to 10 million active users, and every active user triggers a database write every 15 minutes to rotate their refresh token.</p><p>At a peak time, our SQL database crashes under the write pressure from ephemeral tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zPpHAxxUwDv8NQZd" /><figcaption>Photo by <a href="https://unsplash.com/@wwarby?utm_source=medium&amp;utm_medium=referral">William Warby</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The reinforcement we introduce to survive this stressor is Polyglot Persistence. We acknowledge that “Identity Data” (users, not frequently changing) and “Session Data” (tokens, high churn) have different physics.</p><p>We separate the storage architecture, moving high-churn data (tokens) to a Key-Value Store (like Redis or DynamoDB), while keeping the SQL database for stable user profile data.</p><h4>Stressor 2: The Header Overflow (Data Bloat)</h4><p>The next stressor is the “Header Overflow.” A client creates complex roles utilizing the Role-Based Access Control (RBAC) features we provide, and a single user now has 500+ granular permissions.</p><p>The JWT size swells to 15KB, which exceeds the HTTP header limit of most load balancers and CDNs, causing valid requests to be rejected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AOOA55HG1guvZa7a" /><figcaption>Photo by <a href="https://unsplash.com/@padrinan?utm_source=medium&amp;utm_medium=referral">Miguel Ángel Padriñán Alba</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>To survive this stressor, we implement the Claim-Check Pattern. We stop sending the permission data in the token and instead send a key to the data.</p><p>The JWT now contains only a small `artifact_id`, and the permissions are stored in a distributed cache. The API Gateway intercepts the request, retrieves the massive permission set from the cache, and “hydrates” the request context internally.</p><h4>Stressor 3: The Data Gravity Well (Large Media)</h4><p>The final stressor is the “Data Gravity Well.” We allow our users to upload a picture for their profile.</p><p>Some users upload high-resolution profile photos, which are Base64 encoded and saved into a TEXT or BLOB column in the Users table. The database memory fills up with image data, killing performance. To survive this, we introduce Object Storage Indirection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p7KFKebLlEgLslBn" /><figcaption>Photo by <a href="https://unsplash.com/@xue_zheng?utm_source=medium&amp;utm_medium=referral">Zheng XUE</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We move binaries to an Object Store (like AWS S3 or Azure Blob Storage) and store only the URL in the database. This segregates structured data (fast, expensive storage) from unstructured data (slow, cheap storage), ensuring the database can survive high-res content demands.</p><h4>Final Architecture</h4><p>By applying these stressors picked from real-world experiences, our final architecture has evolved significantly.</p><p>We now have <strong>Redis </strong>for caching high-churn data, a<strong> claim-check pattern</strong> for handling large permission sets, and external <strong>object storage </strong>for large media. This architecture is not what we initially designed, but it is what remained after surviving the stressors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dsyu_-BLi9poQgnV" /><figcaption>Photo by <a href="https://unsplash.com/@epsika?utm_source=medium&amp;utm_medium=referral">erika m</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The Residuality Method moves us from guessing future requirements to stress-testing our architecture against chaos that actually happens in the real world.</p><p>By embracing chaos and failures as sources of insight, we can build systems that are resilient, adaptable, and capable of surviving unexpected challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=533127590838" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/the-residuality-method-evolving-an-identity-system-from-naive-to-unbreakable-533127590838">The Residuality Method: Evolving an Identity System from Naive to Unbreakable</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stay ahead of the Information Overflow — Shift to Personalized Podcasts]]></title>
            <link>https://towardsdev.com/stay-ahead-of-the-information-overflow-shift-to-personalized-podcasts-9d387294edbc?source=rss-864232b60728------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d387294edbc</guid>
            <category><![CDATA[podcast]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[information-overload]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gemini]]></category>
            <dc:creator><![CDATA[Pabasara Mahindapala]]></dc:creator>
            <pubDate>Sun, 25 Jan 2026 15:59:15 GMT</pubDate>
            <atom:updated>2026-05-19T08:12:52.798Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stay ahead of the Information Overflow — Shift to Personalized Podcasts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sk3PvnyY1LvAeps9ybt3HA.png" /><figcaption>So much info!</figcaption></figure><p>How many links do you have saved in your reading list right now?</p><p>I have 12 unread articles saved in my reading list and 2798 unread emails in my inbox.</p><p>In a single day, from the moment you wake up to the time you go to bed, you are exposed to more information than your great-great-grandfather encountered in a month.</p><p>With the advancement of digital media, the volume of information we consume has exploded. It can be a notification on your phone, an email from work, a post on social media or an eBook you are trying to read.</p><p>It’s a real challenge to keep up and digest all this information. You no longer have time to simply “sit and read” something.</p><p>This article is about how I leverage the power of listening to keep up with the daily overflow of information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D368NdqKbN--Uqv0GdeE9g.png" /><figcaption>Just a few letters and a newspaper…</figcaption></figure><h4>Podcasts</h4><p>Podcasts have become a popular medium for consuming information. They are convenient, portable, and allow for multitasking.</p><p>A 2024 <a href="https://www.mdpi.com/2227-7102/14/10/1129">study</a> published in Educational Sciences says:</p><blockquote>Podcasts are a powerful medium for self-directed and incidental learning, with listeners actively engaging in knowledge acquisition and retention</blockquote><p>The research revealed that listening in the form of podcasts leads to higher trust in content and more active cognitive engagement compared to other learning methods.</p><p>Additionally, a <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC9733582/">study</a> conducted at the Virginia Tech Carilion School of Medicine used EEG to measure brain attention patterns and found that podcast learning produced <strong>“significantly better learning gain, and equivalent retention”</strong> compared to traditional textbook reading.</p><h4>The problem</h4><p>But which podcast should I listen to?</p><p>There are thousands of podcasts available on various topics. But they do not cover everything I want to know right now. They are not created based on the specific news article I want to read or the specific technical report I have to read and understand before my next meeting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SYVoMl1Op4Z6XF0VT4K2Uw.png" /><figcaption>Which one is right for me?</figcaption></figure><p>What if there was a way to get personalized podcasts that are tailored for you?</p><p>Here are three methods I follow, with a little help from Gemini.</p><h3>1. Google Chrome Mobile “Listen to this page”</h3><p>This is a fairly recent feature in Google Chrome Mobile that converts text heavy web pages into a podcast style audio.</p><p>It’s not the traditional text-to-speech (TTS) that we are used to. Text-to-speech just reads the text top to bottom in it’s monotone robotic voice.</p><p>The “AI Playback” feature under Listen to this page generates a conversational podcast style dialog between two AI voices, summarizing the key points of the page.</p><p>Take this recent news article for example. It’s a bit text heavy article:</p><p><a href="https://www.newswire.lk/2026/01/01/france-plans-social-media-ban-for-children-under-15-reports/">France plans social media ban for children under 15: reports - Newswire</a></p><p>When I visit the page in the Google Chrome Mobile browser, and select “Listen to this page” from the menu, within few seconds it created a 1 minute and 15 seconds long podcast style audio summary of the article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cnKkS6wAzxFtEahsSmLyXw.png" /><figcaption>Listen to this page option</figcaption></figure><p>When I hit play, the audio goes on like this:</p><p><strong><em>Voice 1:</em></strong><em> France is considering a social media ban for children under 15, what’s the background on this?</em></p><p><strong><em>Voice 2:</em></strong><em> Okay, according to reports, the French government is responding to growing concerns about the risk of excessive screen time and online harms. And this initiative follows previous attempts to regulate digital access for young people including a mobile phone ban in schools.</em></p><p><strong><em>Voice 1:</em></strong><em> What challenges has France faced in implementing such a ban?</em></p><p><strong><em>Voice 2:</em></strong><em> A previous attempt to set a digital legal age of 15 was stalled due to conflicts with EU rules…</em></p><p>And the discussion continues.</p><p>It has summarized the key points of the article in a engaging conversational format, making it easy to consume while on the go.</p><p>However, there are few points to note:</p><ul><li>At the time of writing, this feature seems to be available only on Android. iOS Chrome App does not have the “Listen to this page” or the “AI Playback” options yet.</li><li>You may notice that the “Listen to this page” option does not appear on every website. It works best on text based articles, but it will not work on content behind paywalls/authwalls or copyright protected content.</li><li>The summary will be biased based on the source content. It’s basically a reflection of the webpage in a different format. If the article is biased, the summary will be biased too. If the article has inaccuracies, the summary will be inaccurate.</li></ul><h3>2. Google Drive PDF Audio Overviews</h3><p>This is another <a href="https://support.google.com/drive/answer/16685527?hl=en#">recent feature</a> in Google Drive that generates audio summaries for PDF files stored in your Drive.</p><p>You can open a PDF file in Google Drive and select “Create audio overview” to generate a podcast style summary of the document. Once it’s generated, it will be saved in an “Audio overviews” folder in your Drive and you will get an email with the link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*E6OH4rRSkapF9hN87YhLkw.png" /><figcaption>Create an audio overview</figcaption></figure><p>This feature is great for quickly reviewing lengthy technical documents or reports while multitasking.</p><p>I no longer have to skip the long documents in our architecture email group. A document that takes 30 minutes to read can be summarized into a 5 minute audio overview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cSAoDXHXr-D_R0fi5nQE9w.jpeg" /><figcaption>Email with the link</figcaption></figure><h3>3. NotebookLM Audio Overviews</h3><p>If you are not familiar with <strong>NotebookLM</strong>, it’s an research tool from Google that helps you synthesize information from multiple sources.</p><p><a href="https://notebooklm.google/">Gemini Notebook | AI Research Tool &amp; Thinking Partner</a></p><p>According to NotebookLM homepage:</p><blockquote>Upload PDFs, websites, YouTube videos, audio files, Google Docs, Google Slides and more, and NotebookLM will summarize them and make interesting connections between topics, all powered by the latest version of Gemini’s multimodal understanding capabilities.</blockquote><p>The particularly interesting feature for me is the “Audio Overview” that generates a podcast style deep dive discussion between two AI hosts based on all the sources you have uploaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*4Lj9-s75Ly8lLz9Bj_qy_g.png" /><figcaption>Create an audio overview</figcaption></figure><p>This is different from the PDF to audio overview feature in Google Drive. Here, the conversation you listen to is based on multiple sources that you share, or NotebookLM finds for you.</p><p>This provides the ability to have a more comprehensive understanding of complex topics based on the various perspectives presented in the different sources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*zVoGY0dUO_zG40bcmGRn2Q.png" /><figcaption>Play the audio overview</figcaption></figure><p>The two voices discuss the key points, contrasting arguments, and connections between the different sources you have provided. It’s like having a personalized podcast episode tailored to your specific research.</p><p>Unlike the earlier two methods, this let’s you join in the conversation by switching to the <strong>Interactive </strong>mode. You can literally speak to the virtual hosts and ask follow up questions or request clarifications!</p><p>When I select the interactive mode, the host pauses and invites me to ask a question:</p><p><em>Voice 1: It seems one of our listeners wants to join in. Go ahead, what’s your question?</em></p><p>After I ask my question, the host responds and continues the discussion.</p><p>Finally, it should be noted that while these artificial podcasts are powerful tools for consuming a large volume of information quickly, they should not replace deep reading and critical thinking.</p><p><strong>Hallucinations, inaccuracies, sycophancy and biases</strong> are a few real issues with LLM generated audio content that we should be aware of. And I always find the voices overly enthusiastic about every topic!</p><p>A <a href="https://dig.watch/updates/study-finds-ai-summaries-can-flatten-understanding-compared-with-reading-sources">recent study</a> from Wharton found that while LLM generated summaries help users learn faster, they can lead to a “flattening” of understanding, where users remember fewer concrete details compared to reading the full text.</p><p>It is always good practice to use the podcast format summaries to get an overview first, and then dive deeper into the specific documents when necessary for a more thorough understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qPKrL669NneGlqVzqZkEpg.png" /><figcaption>Stay ahead of it!</figcaption></figure><p>By leveraging podcast style summaries, we can stay ahead in the overflow of information while still maintaining critical engagement with the content.</p><p>Let me know your thoughts and experiences if you try this out!</p><p>(Graphics created with Gemini Nano Banana Pro)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d387294edbc" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/stay-ahead-of-the-information-overflow-shift-to-personalized-podcasts-9d387294edbc">Stay ahead of the Information Overflow — Shift to Personalized Podcasts</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>