<?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 Praveen Valaboju on Medium]]></title>
        <description><![CDATA[Stories by Praveen Valaboju on Medium]]></description>
        <link>https://medium.com/@praveen.valaboju1?source=rss-862f7b80bc6b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yszIAepITE8MDipPVjujAA.jpeg</url>
            <title>Stories by Praveen Valaboju on Medium</title>
            <link>https://medium.com/@praveen.valaboju1?source=rss-862f7b80bc6b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 09:23:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@praveen.valaboju1/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[The Evolution of AI Engineering: From Prompting to Harness Engineering]]></title>
            <link>https://medium.com/@praveen.valaboju1/the-evolution-of-ai-engineering-from-prompting-to-harness-engineering-9dc67f137d55?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9dc67f137d55</guid>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Mon, 05 Oct 2026 03:49:29 GMT</pubDate>
            <atom:updated>2026-10-05T03:49:29.993Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Evolution of How We Work with AI</h3><p>Artificial Intelligence has changed rapidly over the last few years.</p><p>As AI models became more capable, the way engineers work with them also changed.</p><p>At a high level, we can think about this evolution in three stages:</p><ol><li><strong>Prompt Engineering</strong></li><li><strong>Context Engineering</strong></li><li><strong>Harness Engineering</strong></li></ol><p>The easiest way to understand the difference is:</p><blockquote><strong><em>Prompt Engineering tells AI what to do.<br>Context Engineering gives AI the information it needs.<br>Harness Engineering creates the system that controls, verifies, and improves how AI does the work.</em></strong></blockquote><h3>1. Prompt Engineering — “How Do I Ask AI?”</h3><p>In the early days of ChatGPT and other Large Language Models, a lot of attention was placed on the <strong>prompt</strong>.</p><p>A prompt is simply the instruction or question we give to the AI.</p><p>For example:</p><blockquote><em>“Write a Python function that reads a CSV file.”</em></blockquote><p>But engineers quickly discovered that the way we asked the question could dramatically affect the answer.</p><p>Instead of:</p><blockquote><em>“Write a Python function.”</em></blockquote><p>We might say:</p><blockquote><em>“You are an experienced Python developer. Write a production-ready Python function that reads a CSV file, validates the input, handles errors, and includes unit tests.”</em></blockquote><p>The second prompt gives the AI much more direction.</p><h3>Why was this important?</h3><p>Engineers experimented with:</p><ul><li>The wording of the request</li><li>The order of instructions</li><li>Examples</li><li>Roles</li><li>Formatting</li><li>Constraints</li><li>Expected output</li></ul><p>Small changes could sometimes produce very different results.</p><h3>The problem</h3><p>This approach could be fragile.</p><p>If the underlying AI model changed, a prompt that worked extremely well yesterday might produce a different result tomorrow.</p><p>So engineers started asking a bigger question:</p><blockquote><strong><em>Instead of only improving the question, can we improve the information we give the AI?</em></strong></blockquote><p>That led to <strong>Context Engineering</strong>.</p><h3>2. Context Engineering — “What Does AI Need to Know?”</h3><p>As AI systems became more capable, companies realized that the model doesn’t always need to be trained again.</p><p>Sometimes, it simply needs access to the <strong>right information at the right time</strong>.</p><p>Imagine asking an employee:</p><blockquote><em>“How do I troubleshoot this production issue?”</em></blockquote><p>If that employee has never seen your system before, they may not know the answer.</p><p>But if you give them:</p><ul><li>The architecture document</li><li>The API documentation</li><li>Recent logs</li><li>Configuration information</li><li>Troubleshooting guides</li><li>Previous incident reports</li></ul><p>they can make a much better decision.</p><p>The same idea applies to AI.</p><h3>Context can include:</h3><ul><li>Company documentation</li><li>Source code</li><li>Databases</li><li>API responses</li><li>Customer information</li><li>System logs</li><li>Previous conversations</li><li>Configuration files</li><li>Business rules</li></ul><p>For example, instead of asking:</p><blockquote><em>“Why is my application failing?”</em></blockquote><p>we can give the AI:</p><blockquote><em>Application logs + architecture documentation + configuration + recent deployment information</em></blockquote><p>and then ask it to investigate the problem.</p><p>This usually produces a much more useful result.</p><h3>But There Is a Problem With Too Much Context</h3><p>More information isn’t always better.</p><p>Imagine someone asks:</p><blockquote><em>“What is the procedure for restarting this service?”</em></blockquote><p>And instead of giving them the relevant procedure, we hand them an entire 2,000-page company library.</p><p>They now have to figure out:</p><ul><li>Which document matters?</li><li>Which section matters?</li><li>Which information is outdated?</li><li>Which instructions apply to this system?</li><li>Which rules take priority?</li></ul><p>The AI faces a similar problem.</p><p>So the goal isn’t:</p><blockquote><strong><em>Give AI everything.</em></strong></blockquote><p>The goal is:</p><blockquote><strong><em>Give AI the right information when it needs it.</em></strong></blockquote><p>This led to another evolution:</p><h3>3. Harness Engineering — “How Do We Make AI Work Reliably?”</h3><p>This is where the idea of <strong>Harness Engineering</strong> becomes important.</p><p>A harness is the system surrounding the AI.</p><p>Think about a horse.</p><p>A rider doesn’t simply tell the horse:</p><blockquote><em>“Go somewhere useful.”</em></blockquote><p>The rider has a structure that helps control the horse:</p><ul><li>Reins</li><li>Saddle</li><li>Bridle</li><li>Directions</li><li>Rules</li><li>Feedback</li></ul><p>The harness gives the rider a way to guide and control the process.</p><p>AI agents need something similar.</p><h3>What Does an AI Harness Do?</h3><p>An AI harness can define:</p><h3>1. What the AI is allowed to do</h3><p>For example:</p><blockquote><em>The AI can read application logs.</em></blockquote><p>But:</p><blockquote><em>The AI cannot delete production data.</em></blockquote><h3>2. What tools the AI can use</h3><p>For example, an AI coding agent might have access to:</p><ul><li>Git</li><li>A terminal</li><li>A database</li><li>Test tools</li><li>Documentation</li><li>Cloud APIs</li></ul><p>But it doesn’t necessarily have unlimited access to everything.</p><h3>3. What information the AI should access</h3><p>The harness can tell the AI:</p><blockquote><em>“If you are working on database code, read the database documentation.”</em></blockquote><p>But:</p><blockquote><em>“Don’t load the entire documentation library.”</em></blockquote><p>This keeps the AI focused.</p><h3>4. How the AI’s work should be verified</h3><p>The AI might write code.</p><p>But we shouldn’t simply assume the code is correct.</p><p>The harness can require:</p><blockquote><em>Run the type checker.</em></blockquote><p>Then:</p><blockquote><em>Run the tests.</em></blockquote><p>Then:</p><blockquote><em>Verify the result.</em></blockquote><p>The AI isn’t just producing an answer.</p><p>It is <strong>checking its work</strong>.</p><h3>5. What happens when something goes wrong</h3><p>This is one of the most important parts.</p><p>Suppose the AI changes some code and the tests fail.</p><p>Instead of simply saying:</p><blockquote><em>“The tests failed.”</em></blockquote><p>the harness can provide a recovery process:</p><ol><li>Capture the exact error.</li><li>Look at the relevant troubleshooting documentation.</li><li>Make one targeted change.</li><li>Run the test again.</li><li>If it still fails, investigate further or ask for help.</li></ol><p>This creates a <strong>feedback loop</strong>.</p><p>The AI performs an action, observes the result, and adjusts based on what happened.</p><h3>A Simple Example</h3><p>Imagine we ask an AI coding agent:</p><blockquote><em>“Add a new login feature to our application.”</em></blockquote><p>A basic AI might immediately start writing code.</p><p>A harness-driven AI would follow a process more like this:</p><pre>Understand the task<br>       ↓<br>Read relevant project rules<br>       ↓<br>Read authentication documentation<br>       ↓<br>Inspect existing code<br>       ↓<br>Make the change<br>       ↓<br>Run type checking<br>       ↓<br>Run automated tests<br>       ↓<br>      ┌───────────────┐<br>      │ Tests pass?   │<br>      └───────┬───────┘<br>          Yes │ No<br>              │<br>       Continue      Investigate<br>                       ↓<br>                    Fix issue<br>                       ↓<br>                    Test again</pre><p>The important difference is that the AI is operating inside a <strong>defined engineering process</strong>.</p><h3>AGENTS.md — Giving the AI a Project Handbook</h3><p>One practical example of this approach is an AGENTS.md file.</p><p>Think of AGENTS.md as an <strong>employee handbook for an AI coding agent</strong>.</p><p>It can explain:</p><ul><li>How the project is structured</li><li>What technologies are used</li><li>What rules the AI must follow</li><li>What commands it should run</li><li>What it must never do</li><li>Where it should look for documentation</li><li>How it should handle errors</li></ul><p>For example:</p><h3>AGENTS.md</h3><h3>Technology Standards</h3><p>This project uses:</p><ul><li>TypeScript</li><li>Node.js 20+</li><li>Next.js</li><li>PostgreSQL</li><li>Prisma</li><li>Vitest</li><li>Playwright</li></ul><p>The AI should follow the existing architecture rather than introducing unnecessary technologies.</p><h3>Quality Checks</h3><p>Before considering a code change complete:</p><ol><li>Run the type checker.</li><li>Run the automated tests.</li><li>Add tests for new utilities or important functionality.</li><li>Fix failures before declaring the task complete.</li></ol><p>For example:</p><pre>npm run typecheck<br>npm test</pre><p>The purpose is simple:</p><blockquote><strong><em>Don’t just generate code. Verify the code.</em></strong></blockquote><h3>Safety Rules</h3><p>Some operations can cause serious damage.</p><p>For example:</p><blockquote><em>Never execute </em><em>git reset --hard without explicit approval.</em></blockquote><p>And:</p><blockquote><em>Never drop production database tables without explicit approval.</em></blockquote><p>This prevents the AI from making a technically valid but potentially dangerous decision.</p><h3>Documentation Rules</h3><p>The AI doesn’t need to read the entire company documentation library.</p><p>Instead, we can provide a map.</p><p>For example:</p><pre>Working on database models?<br>→ Read docs/database-schema.md</pre><pre>Working on UI?<br>→ Read docs/design-system.md</pre><pre>Working on APIs?<br>→ Read docs/api-routes.md</pre><pre>Troubleshooting a failure?<br>→ Read docs/troubleshooting.md</pre><p>This is an example of <strong>progressive disclosure</strong>.</p><p>The AI gets information when it is relevant rather than receiving everything at once.</p><h3>Error Recovery</h3><p>Now consider what happens when something fails.</p><p>Suppose the AI runs the tests and receives:</p><pre>Test failed:<br>Expected 200<br>Received 500</pre><p>Instead of randomly changing code again and again, the project rules can define a recovery process:</p><h3>Step 1 — Capture the error</h3><p>Record the exact error message.</p><h3>Step 2 — Find relevant information</h3><p>Read the troubleshooting documentation.</p><h3>Step 3 — Make one targeted change</h3><p>Don’t randomly modify five different parts of the application.</p><h3>Step 4 — Test again</h3><p>Run the same verification.</p><h3>Step 5 — Escalate if necessary</h3><p>If the problem cannot be resolved after a reasonable number of attempts, ask the human engineer.</p><p>This is important because a good AI system should know not only <strong>how to act</strong>, but also <strong>when to stop acting</strong>.</p><h3>Why Is This Different From Just Giving AI a Prompt?</h3><p>Consider two approaches.</p><h3>Approach 1 — Prompt Only</h3><blockquote><em>“Fix the login bug.”</em></blockquote><p>The AI may:</p><ul><li>Inspect some code</li><li>Make a change</li><li>Tell you it fixed the problem</li></ul><p>But did it actually work?</p><p>You don’t know.</p><h3>Approach 2 — Harness</h3><p>The instruction becomes:</p><blockquote><em>“Fix the login bug.”</em></blockquote><p>But the surrounding system says:</p><ol><li>Read the authentication documentation.</li><li>Inspect the existing implementation.</li><li>Make the smallest appropriate change.</li><li>Run type checking.</li><li>Run the tests.</li><li>If tests fail, investigate the exact error.</li><li>Retry the fix.</li><li>Do not perform destructive operations without approval.</li><li>Report what was changed and what was verified.</li></ol><p>Now the AI is operating inside a <strong>controlled engineering process</strong>.</p><p>That’s the key difference.</p><h3>The Three Concepts Together</h3><p>These three ideas aren’t competing with each other.</p><p>They work together.</p><h3>Prompt Engineering</h3><p>Controls the <strong>instruction</strong>.</p><blockquote><em>“Fix the login bug.”</em></blockquote><h3>Context Engineering</h3><p>Provides the <strong>knowledge</strong>.</p><blockquote><em>“Here is the authentication architecture, relevant code, logs, and documentation.”</em></blockquote><h3>Harness Engineering</h3><p>Controls the <strong>process</strong>.</p><blockquote><em>“Here are the tools you can use, the rules you must follow, the checks you must perform, and what to do when something goes wrong.”</em></blockquote><p>So we can visualize the relationship like this:</p><pre>AI SYSTEM<br>                     │<br>                     ▼<br>          ┌─────────────────────┐<br>          │ Prompt Engineering  │<br>          │ What should I do?   │<br>          └──────────┬──────────┘<br>                     │<br>                     ▼<br>          ┌─────────────────────┐<br>          │ Context Engineering │<br>          │ What should I know? │<br>          └──────────┬──────────┘<br>                     │<br>                     ▼<br>          ┌─────────────────────┐<br>          │ Harness Engineering │<br>          │ How should I work?  │<br>          └──────────┬──────────┘<br>                     │<br>                     ▼<br>              Tools + Rules<br>                     │<br>                     ▼<br>                Validation<br>                     │<br>              ┌──────┴──────┐<br>              │             │<br>            Success       Failure<br>              │             │<br>              ▼             ▼<br>           Continue      Recover</pre><h3>Why Harness Engineering Matters</h3><p>As AI moves from answering questions to <strong>performing real work</strong>, reliability becomes much more important.</p><p>A chatbot can give you a bad answer.</p><p>An AI agent with access to your source code, cloud infrastructure, databases, and production systems can potentially cause a much bigger problem.</p><p>Therefore, we need more than intelligence.</p><p>We need:</p><ul><li>Rules</li><li>Permissions</li><li>Validation</li><li>Testing</li><li>Observability</li><li>Documentation</li><li>Human approval</li><li>Error recovery</li><li>Clear boundaries</li></ul><p>This is why harness engineering is becoming increasingly important for AI-powered software systems.</p><h3>The Bigger Shift</h3><p>The fundamental change is this:</p><h3>Before</h3><p>We primarily asked:</p><blockquote><strong><em>“How do I get the AI to give me a better answer?”</em></strong></blockquote><h3>Now</h3><p>We’re increasingly asking:</p><blockquote><strong><em>“How do I build a system where the AI can reliably perform useful work?”</em></strong></blockquote><p>That’s a much bigger engineering problem.</p><p>It involves not only AI models, but also:</p><ul><li>Software engineering</li><li>System architecture</li><li>Security</li><li>Testing</li><li>Observability</li><li>Automation</li><li>Access control</li><li>Documentation</li><li>Human oversight</li></ul><p>The AI model is only one component.</p><p>The <strong>system around the model</strong> is what makes it useful in production.</p><h3>A Simple Real-World Analogy</h3><p>Imagine hiring a very intelligent new employee.</p><p>You could simply tell them:</p><blockquote><em>“Go work on the application.”</em></blockquote><p>That probably won’t work very well.</p><p>Instead, you give them:</p><h3>A job description</h3><p>What are they supposed to accomplish?</p><h3>A company handbook</h3><p>What rules must they follow?</p><h3>Documentation</h3><p>How does the company operate?</p><h3>Tools</h3><p>What systems are they allowed to use?</p><h3>Permissions</h3><p>What are they allowed to change?</p><h3>Quality checks</h3><p>How do we know their work is correct?</p><h3>Escalation process</h3><p>What should they do when they get stuck?</p><p>That entire structure is similar to an <strong>AI harness</strong>.</p><p>The AI is the worker.</p><p>The harness is the <strong>engineering environment that allows the worker to operate safely and effectively</strong>.</p><h3>The Evolution in One Picture</h3><pre>2023–2024<br>PROMPT ENGINEERING</pre><pre>        ↓</pre><pre>“How should I ask AI?”</pre><pre>        ↓</pre><pre>2025<br>CONTEXT ENGINEERING</pre><pre>        ↓</pre><pre>“What information does AI need?”</pre><pre>        ↓</pre><pre>Today<br>HARNESS ENGINEERING</pre><pre>        ↓</pre><pre>“How do I make AI reliably perform<br>work inside a controlled system?”</pre><pre>        ↓</pre><pre>Future AI Systems</pre><pre>AI + Tools + Context + Rules<br>       + Validation<br>       + Observability<br>       + Feedback<br>       + Recovery<br>       + Human Oversight</pre><h3>Final Takeaway</h3><p>The evolution of AI engineering can be summarized in three questions:</p><h3>Prompt Engineering</h3><blockquote><strong><em>What should I ask the AI to do?</em></strong></blockquote><h3>Context Engineering</h3><blockquote><strong><em>What information does the AI need to do it correctly?</em></strong></blockquote><h3>Harness Engineering</h3><blockquote><strong><em>How do I create an environment where the AI can perform the task safely, verify its work, and recover when things go wrong?</em></strong></blockquote><p>And that leads to the simplest summary:</p><blockquote><strong><em>Prompt Engineering shapes what AI is asked to do.<br>Context Engineering gives AI the knowledge it needs.<br>Harness Engineering creates the system that allows AI to reliably and safely get the work done.</em></strong></blockquote><p>The future isn’t just about building smarter AI.</p><p>It is also about building <strong>better systems around AI</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9dc67f137d55" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DCM4Chee DICOM TLS Setup: A DevOps Guide to Secure PACS with BCP 195 Compliance]]></title>
            <link>https://medium.com/@praveen.valaboju1/dcm4chee-dicom-tls-setup-a-devops-guide-to-secure-pacs-with-bcp-195-compliance-50882159da0b?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/50882159da0b</guid>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Sun, 12 Oct 2025 21:29:44 GMT</pubDate>
            <atom:updated>2025-10-13T05:32:49.007Z</atom:updated>
            <content:encoded><![CDATA[<h3>🏥 What Is DCM4Chee?</h3><p><strong>DCM4Chee</strong> is an open-source, enterprise-grade <strong>PACS (Picture Archiving and Communication System)</strong> and <strong>DICOM archive</strong> developed by the <a href="https://www.dcm4che.org/">DCM4CHE project</a>. It is widely used in hospitals, imaging centers, and research environments to <strong>store, manage, and route medical imaging data</strong> (such as CT, MRI, PET, and X-ray studies) in compliance with the <strong>DICOM</strong> (Digital Imaging and Communications in Medicine) standard.</p><p>At its core, DCM4Chee acts as a <strong>DICOM Application Entity</strong> that supports secure communication between imaging modalities, radiology workstations, and vendor systems. It enables healthcare institutions to maintain a <strong>centralized, standards-compliant image repository</strong> capable of handling millions of studies while integrating seamlessly with <strong>RIS/HIS systems</strong> and external VNA (Vendor Neutral Archive) platforms.</p><h3>🔍 Key Capabilities</h3><ul><li><strong>DICOM Store/Query/Retrieve</strong> services (C-STORE, C-FIND, C-MOVE, and C-GET)</li><li><strong>HL7 integration</strong> for patient and order synchronization</li><li><strong>Multi-tenant architecture</strong> with support for clustering and replication</li><li><strong>Web-based UI</strong> for administrative control and monitoring</li><li><strong>Advanced routing and forwarding</strong> rules for modalities and remote PACS nodes</li><li><strong>Vendor Neutral Archive (VNA) support</strong>, allowing storage of both DICOM and non-DICOM content</li><li><strong>TLS/SSL support</strong> for encrypted data transfer, ensuring compliance with HIPAA and modern security baselines</li></ul><p>Originally built on <strong>Java EE and WildFly</strong>, DCM4Chee has evolved into a container-ready solution with official <strong>Docker images</strong>, making it popular among <strong>DevOps engineers</strong> and <strong>PACS administrators</strong> for automated, scalable deployments in hospital networks and cloud environments.</p><h3>DCM4Chee BCP 195 Compliance: Complete Step-by-Step Implementation Guide</h3><p><strong>Overview</strong>: The DICOM BCP 195 profile (RFC 8996/9325) mandates strict TLS security: TLS 1.2 (and ideally 1.3) only, strong key exchanges (ECDHE/DHE), AES‐GCM or ChaCha20 ciphers, and no weak algorithms (no RC4/MD5/SHA‑1/null ciphers). All communications must be encrypted with integrity. The standard even <em>recommends</em> using port <strong>2762</strong> for DICOM-over-TLS (DIMSE). In practice, this means replacing default (AES128-SHA, etc.) ciphers with BCP 195-compliant suites (e.g. TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384). DCM4Chee (Archive 5.x) requires the TLS certificate and key in a Java keystore (PKCS12 or JKS) on each node. The following steps create the needed certs/keystores, enforce strong ciphers at the LDAP device level, and deploy DCM4Chee with Docker so that it meets BCP 195 requirements.</p><p><strong>Goal</strong>: Update DCM4Chee from weak default ciphers to BCP 195‑approved ciphers (ECDHE/DHE with AES-GCM/ChaCha20) and TLS 1.2+, <strong>regardless of certificate type</strong> (Let’s Encrypt, commercial, or self-signed).</p><h3>🚀 Quick Start Summary</h3><ul><li><strong>What You’ll Do</strong>: Prepare certificates &amp; keystores; configure LDAP (device) with BCP 195 cipher suites; set up Docker Compose for LDAP, Postgres, and the DCM4Chee Archive; run an automated deployment script; verify TLS security.</li><li><strong>DevOps-Friendly</strong>: Uses official DCM4Chee Docker images. For example, the dcm4che/slapd-dcm4chee image automatically loads the necessary DICOM/Archive schemas at startup<a href="https://github.com/dcm4che-dockerfiles/slapd-dcm4chee#:~:text=%60dicom.ldif%20dcm4che.ldif%20dcm4chee,default">github.com</a>.</li><li><strong>Time Required</strong>: ~90 minutes total (30 min prep, 45 min config/deploy, 15 min testing).</li></ul><h3>Step 1: Certificate Preparation</h3><p>DCM4Chee requires a <strong>PKCS12 keystore</strong> (or JKS) containing the server’s private key and certificate. It is recommended (and often required) that RSA keys be <strong>≥2048 bits</strong> for compliance. We will start by organizing our directories and importing whatever certificates we have.</p><p>1.1 Create Directory Structure</p><pre># Main project directory<br>mkdir -p dcm4chee-bcp195-deployment<br>cd dcm4chee-bcp195-deployment<br><br># Subdirectories for certs, keystores, scripts, and data<br>mkdir -p certs<br>mkdir -p keystores<br>mkdir -p docker-entrypoint.d<br>mkdir -p var/dcm4chee-arc/db</pre><h3>1.2 Prepare Your Certificates</h3><p><strong>(A) If you have PEM files</strong> (common scenario):</p><pre># Copy your certs into the certs/ directory<br>cp /path/to/your/certificate.crt certs/publiccert.pem<br>cp /path/to/your/private.key certs/privatekey.pem<br># Optional: the CA chain (intermediate + root) <br>cp /path/to/your/ca-chain.crt certs/ca-chain.pem</pre><p><strong>(B) If you have a PKCS#12/PFX file</strong>:</p><pre># Extract into PEM components (you may need the PFX password)<br>openssl pkcs12 -in your-certificate.p12 -clcerts -nokeys -out certs/publiccert.pem<br>openssl pkcs12 -in your-certificate.p12 -nocerts -nodes -out certs/privatekey.pem<br>openssl pkcs12 -in your-certificate.p12 -cacerts -nokeys -out certs/ca-chain.pem</pre><p><strong>(C)If you have separate cert and chain</strong>:</p><pre># Combine server cert with intermediates (so they all load properly)<br>cat your-certificate.crt intermediate.crt &gt; certs/publiccert.pem<br>cp your-private.key certs/privatekey.pem<br>cp root-ca.crt certs/ca-chain.pem</pre><p><strong><em>Note</em></strong><em>:</em> DCM4Chee’s TLS conformance requires the private key and certificate to be in a local keystore (PKCS12 or JKS)We’ll convert our PEM (or PFX) into PKCS12 in the next step.</p><p><strong>1.3 Verify Certificate Files</strong></p><pre># Check the server certificate<br>openssl x509 -in certs/publiccert.pem -text -noout<br><br># Check the private key<br>openssl rsa -in certs/privatekey.pem -check -noout<br><br># Ensure certificate and key match:<br>openssl x509 -noout -modulus -in certs/publiccert.pem | openssl md5<br>openssl rsa -noout -modulus -in certs/privatekey.pem | openssl md5<br># (Hashes must be identical.)</pre><p>Also confirm <strong>key length</strong> (should be ≥2048 bits for RSA) and expiration dates. BCP 195 requires RSA keys ≥2048 bits. If any check fails, correct your files before proceeding.</p><ol><li><strong>4 Set Proper Permissions</strong></li></ol><pre>chmod 644 certs/publiccert.pem<br>chmod 600 certs/privatekey.pem<br>chmod 644 certs/ca-chain.pem</pre><p>This restricts private key access (required by best practices) while allowing the server to read the certs.</p><h3>🔧 Step 2: Create Java Keystores</h3><p>Now convert the PEM certificates into a Java <strong>PKCS12 keystore</strong> and a truststore. We’ll use openssl and keytool.</p><h3>2.1 Generate PKCS#12 Keystore</h3><pre># Create keystores directory<br>mkdir -p keystores</pre><pre># Generate PKCS#12 keystore containing our cert and key<br>openssl pkcs12 -export \<br>    -in certs/publiccert.pem \<br>    -inkey certs/privatekey.pem \<br>    -out keystores/key.p12 \<br>    -name &quot;dcm4chee&quot; \<br>    -passout pass:secret</pre><pre>#Why PKCS12? As per the DICOM conformance, DCM4Chee expects the identifying certificate/key in a keystore (PKCS12 or JKS) on the hostdcm4chee-arc-hl7cs.readthedocs.io. We use PKCS12 for simplicity.</pre><h3>2.2 Create Trust Store</h3><pre># If you have CA chain, import it as a truststore<br>keytool -import -trustcacerts \<br>    -alias ca-root \<br>    -file certs/ca-chain.pem \<br>    -keystore keystores/cacerts.p12 \<br>    -storetype PKCS12 \<br>    -storepass secret \<br>    -noprompt</pre><pre># (Optional) For client cert auth, we can reuse the same truststore:<br>cp keystores/cacerts.p12 keystores/client-truststore.p12</pre><p>This cacerts.p12 will contain your CA certificates (used by the Archive when verifying remote client certs). If no CA chain was provided, the script above will create an empty PKCS12 store (with a dummy entry we then delete).</p><h3>2.3 Verify Keystores</h3><pre># List entries in the server keystore<br>keytool -list -keystore keystores/key.p12 -storetype PKCS12 -storepass secret</pre><pre># List entries in the truststore<br>keytool -list -keystore keystores/cacerts.p12 -storetype PKCS12 -storepass secret</pre><p>You should see your certificate alias (and any imported CA) in the listings. If something is missing, review Step 2.2 (truststore creation).</p><h3>📝 Step 3: Create LDIF Configuration Files</h3><p>DCM4Chee stores device configurations (including TLS settings) in an LDAP repository. We’ll prepare LDIF files to modify the dicomDeviceName=dcm4chee-arc,cn=Devices,cn=DICOM Configuration,dc=dcm4che,dc=org entry with our new TLS parameters.</p><h3>3.1 BCP 195 Cipher Configuration</h3><p>Create 01-bcp195-dicom-ciphers.ldif:</p><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmTLSCipherSuite<br>dcmTLSCipherSuite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384<br>dcmTLSCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256<br>dcmTLSCipherSuite: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256<br>dcmTLSCipherSuite: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384<br>dcmTLSCipherSuite: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256</pre><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmTLSProtocol<br>dcmTLSProtocol: TLSv1.2<br>dcmTLSProtocol: TLSv1.3</pre><p>This enforces only the strong cipher suites needed for BCP 195. The DICOM profile requires support for AES-GCM and ChaCha20 with ECDHE or DHE key exchange. We explicitly set TLSv1.2 and TLSv1.3 only (no SSLv3/TLSv1.0/1.1) in line with BCP 195.</p><p><em>Citation:</em> DICOM B.13 “Modified BCP 195” lists these ciphers for TLS 1.2 as required suites. The DICOM security profile explicitly <strong>disallows</strong> older ciphers (like 3DES, RC4, MD5, SHA-1), so our list matches the allowed set.</p><h3>3.2 Client Certificate Authentication (Optional)</h3><p>If you need <em>mutual TLS</em> (requiring clients to present a certificate), create 02-client-cert-auth.ldif:</p><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmTLSNeedClientAuth<br>dcmTLSNeedClientAuth: true</pre><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmTrustStoreURL<br>dcmTrustStoreURL: file:${jboss.server.config.dir}/keystores/client-truststore.p12</pre><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmTrustStoreType<br>dcmTrustStoreType: PKCS12</pre><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmTrustStorePin<br>dcmTrustStorePin: secret</pre><p>This enables client certificate auth (NeedClientAuth: true) and points to a PKCS12 truststore for verifying client certs. The dcmTrustStoreURL/Type/Pin attributes tell DCM4Chee where to find the CA certificates for trusted clients.</p><h3>3.3 Complete Key/Trust Store Configuration</h3><p>Finally, create 03-complete-bcp195-config.ldif to point DCM4Chee at our keystores:</p><pre># TLS Key/Trust Store Configuration<br>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmKeyStoreURL<br>dcmKeyStoreURL: file:${jboss.server.config.dir}/keystores/key.p12</pre><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmKeyStoreType<br>dcmKeyStoreType: PKCS12</pre><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmKeyStorePin<br>dcmKeyStorePin: secret</pre><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmKeyManagerAlgorithm<br>dcmKeyManagerAlgorithm: SunX509</pre><pre>dn: cn=dicom,ou=Devices,dc=dcm4che,dc=org<br>changetype: modify<br>replace: dcmTrustManagerAlgorithm<br>dcmTrustManagerAlgorithm: SunX509</pre><p>This tells DCM4Chee the file, type, and password for its TLS keystore (containing our server certificate/key). The attributes dcmKeyStoreURL, dcmKeyStoreType, and dcmKeyStorePin correspond exactly to the <strong>Key Store URL/Type/Pin</strong> fields in the device configuration. We also set the standard Java SunX509 manager algorithms for PKCS12.</p><h3>3.4 Upload Script</h3><p>Save this shell script (upload-all.sh) to apply all LDIFs via LDAP:</p><pre># Usage: ./upload-all.sh &lt;ldap-host&gt; &lt;admin-password&gt;</pre><pre>LDAP_HOST=${1:-localhost}<br>ADMIN_PASSWORD=${2:-secret}</pre><pre>echo &quot;🔧 Applying BCP 195 LDAP configurations...&quot;</pre><pre># Apply cipher/protocol configuration<br>ldapmodify -x -H ldap://${LDAP_HOST}:389 \<br>    -D &quot;cn=admin,dc=dcm4che,dc=org&quot; -w ${ADMIN_PASSWORD} \<br>    -f 01-bcp195-dicom-ciphers.ldif</pre><pre>if [ $? -eq 0 ]; then<br>    echo &quot;✅ Cipher configuration applied successfully&quot;<br>else<br>    echo &quot;❌ Failed to apply cipher configuration&quot;<br>    exit 1<br>fi</pre><pre># (Optional) Apply client cert auth config<br>if [ -f &quot;02-client-cert-auth.ldif&quot; ]; then<br>    ldapmodify -x -H ldap://${LDAP_HOST}:389 \<br>        -D &quot;cn=admin,dc=dcm4che,dc=org&quot; -w ${ADMIN_PASSWORD} \<br>        -f 02-client-cert-auth.ldif<br>    if [ $? -eq 0 ]; then<br>        echo &quot;✅ Client-cert config applied&quot;<br>    else<br>        echo &quot;❌ Failed to apply client-cert config&quot;<br>        exit 1<br>    fi<br>fi</pre><pre># Apply keystore/truststore configuration<br>ldapmodify -x -H ldap://${LDAP_HOST}:389 \<br>    -D &quot;cn=admin,dc=dcm4che,dc=org&quot; -w ${ADMIN_PASSWORD} \<br>    -f 03-complete-bcp195-config.ldif</pre><pre>if [ $? -eq 0 ]; then<br>    echo &quot;✅ Keystore configuration applied successfully&quot;<br>else<br>    echo &quot;❌ Failed to apply keystore configuration&quot;<br>    exit 1<br>fi</pre><pre>echo &quot;🎉 All LDAP configurations applied!&quot;<br>echo &quot;📋 Next: Restart DCM4Chee services to apply changes.&quot;</pre><p>Make it executable: chmod +x upload-all.sh. This script uses ldapmodify to upload our configuration to the DCM4Chee LDAP. (If you don’t have ldapmodify on your host, the deployment script below can run it inside the LDAP container.)</p><h3>🐳 Step 4: Create Docker Configuration</h3><p>We’ll deploy DCM4Chee, a PostgreSQL DB, and OpenLDAP using Docker Compose. <strong>All these images are official</strong>:</p><p><strong>LDAP</strong>: dcm4che/slapd-dcm4chee – an OpenLDAP image preloaded with DCM4Chee schemas.</p><p><strong>Postgres</strong>: postgres:13 – holds the PACS database.</p><p><strong>DCM4Chee Archive</strong>: dcm4che/dcm4chee-arc-psql:5.26.1 – WildFly-based DICOM/PACS archive.</p><p><strong>Logstash</strong>: for logs (optional; not related to TLS).</p><p>Save this docker-compose.yml:</p><pre>cat &gt; docker-compose.yml &lt;&lt; &#39;EOF&#39;<br>version: &quot;3.8&quot;<br>services:<br>  ldap:<br>    image: dcm4che/slapd-dcm4chee:2.6.0-26.1<br>    ports:<br>      - &quot;389:389&quot;<br>    environment:<br>      STORAGE_DIR: /storage/fs1<br>    volumes:<br>      - ./var/slapd:/var/lib/openldap/openldap-data<br>      - ./var/slapd/config:/etc/openldap/slapd.d</pre><pre>  db:<br>    image: postgres:13<br>    ports:<br>      - &quot;5432:5432&quot;<br>    environment:<br>      POSTGRES_DB: pacsdb<br>      POSTGRES_USER: pacs<br>      POSTGRES_PASSWORD: pacs<br>    volumes:<br>      - ./var/dcm4chee-arc/db:/var/lib/postgresql/data</pre><pre>  arc:<br>    image: dcm4che/dcm4chee-arc-psql:5.26.1<br>    ports:<br>      - &quot;8080:8080&quot;    # UI<br>      - &quot;8443:8443&quot;    # HTTPS<br>      - &quot;9990:9990&quot;    # JBoss CLI<br>      - &quot;9993:9993&quot;    # JBoss https management<br>      - &quot;11112:11112&quot;  # DICOM (DIMSE)<br>      - &quot;2762:2762&quot;    # DICOM over TLS (DIMSE)<br>      ...<br>    environment:<br>      POSTGRES_DB: pacsdb<br>      POSTGRES_USER: pacs<br>      POSTGRES_PASSWORD: pacs<br>      POSTGRES_HOST: db<br>      WILDFLY_CHOWN: /storage<br>      WILDFLY_WAIT_FOR: ldap:389 db:5432<br>      JAVA_OPTS: &gt;-<br>        -Djavax.net.ssl.trustStore=/opt/wildfly/standalone/configuration/keystores/cacerts.p12<br>        -Djavax.net.ssl.trustStorePassword=secret<br>        -Djavax.net.ssl.trustStoreType=PKCS12<br>        -Djavax.net.ssl.keyStore=/opt/wildfly/standalone/configuration/keystores/key.p12<br>        -Djavax.net.ssl.keyStorePassword=secret<br>        -Djavax.net.ssl.keyStoreType=PKCS12<br>        -Dhttps.protocols=TLSv1.2,TLSv1.3<br>        -Djdk.tls.client.protocols=TLSv1.2,TLSv1.3<br>      # BCP 195 cipher settings (Elytron/WildFly)<br>      CIPHER_SUITE_FILTER: &quot;TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256&quot;<br>      SSL_CIPHER_SUITE_FILTER: &quot;ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-CHACHA20-POLY1305&quot;<br>      SSL_HONOR_CIPHER_ORDER: &quot;true&quot;<br>      JAVAX_NET_SSL_CIPHER_SUITES: &quot;TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256&quot;<br>    depends_on:<br>      - ldap<br>      - db<br>    volumes:<br>      - ./var/dcm4chee-arc:/storage<br>      - ./keystores:/opt/wildfly/standalone/configuration/keystores:ro<br>      - ./docker-entrypoint.d:/docker-entrypoint.d:ro</pre><pre>  logstash:<br>    image: dcm4che/logstash-dcm4chee:7.15.2-26.1<br>    ports:<br>      - &quot;12201:12201/udp&quot;<br>      - &quot;8514:8514/udp&quot;<br>      - &quot;8514:8514&quot;<br>    volumes:<br>      - ./var/logstash/config:/usr/share/logstash/config:ro<br>EOF</pre><p>In this compose file:</p><p><strong>LDAP (</strong><strong>dcm4che/slapd-dcm4chee)</strong> listens on 389 and auto-loads the DICOM/Archive schemas<a href="https://github.com/dcm4che-dockerfiles/slapd-dcm4chee#:~:text=%60dicom.ldif%20dcm4che.ldif%20dcm4chee,default">github.com</a>.</p><p><strong>Archive (</strong><strong>dcm4che/dcm4chee-arc-psql)</strong> exposes port 2762 for secure DIMSE (as recommended<a href="https://dicom.nema.org/medical/dicom/current/output/chtml/part15/sect_b.12.html#:~:text=Note">dicom.nema.org</a>). We mount our keystores/ so WildFly can load key.p12 and cacerts.p12.</p><p>We set Java system properties (-Djavax.net.ssl.*) and WildFly/Elytron env vars to enforce TLSv1.2/1.3 and the specific ciphers. (Elytron’s CIPHER_SUITE_FILTER uses JSSE names matching our dcmTLSCipherSuite above.)</p><h3>4.2 Create Environment File</h3><pre>cat &gt; docker-compose.env &lt;&lt; &#39;EOF&#39;<br># Database<br>POSTGRES_DB=pacsdb<br>POSTGRES_USER=pacs<br>POSTGRES_PASSWORD=pacs</pre><pre># LDAP<br>LDAP_ROOTPASS=secret</pre><pre># Java security<br>JAVA_OPTS_SECURITY=-Djava.security.egd=file:/dev/./urandom</pre><pre># BCP 195 Cipher Configuration<br>CIPHER_SUITE_FILTER=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256<br>SSL_CIPHER_SUITE_FILTER=ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256<br>SSL_HONOR_CIPHER_ORDER=true<br>JAVAX_NET_SSL_CIPHER_SUITES=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256</pre><pre># Keystore paths (inside container)<br>KEYSTORE_PATH=/opt/wildfly/standalone/configuration/keystores/key.p12<br>KEYSTORE_PASSWORD=secret<br>TRUSTSTORE_PATH=/opt/wildfly/standalone/configuration/keystores/cacerts.p12<br>TRUSTSTORE_PASSWORD=secret<br>EOF</pre><p>This file provides environment variables (used by our scripts and Docker images) for DB and LDAP passwords, and re-states the cipher filters for clarity. It ensures the Archive container knows where our keystores are and what the passwords are.</p><h3>🔧 Step 5: Create Deployment Script</h3><p>To tie everything together, we use a bash script (deploy-dcm4chee-bcp195.sh) that checks prerequisites, validates certs, builds keystores, launches containers, uploads LDAP configs, and verifies TLS compliance. Below is the complete script (make sure to chmod +x it):</p><pre>#!/bin/bash<br># DCM4Chee BCP 195 Deployment Script<br>set -e<br>SCRIPT_DIR=&quot;$(cd &quot;$(dirname &quot;${BASH_SOURCE[0]}&quot;)&quot; &amp;&amp; pwd)&quot;<br>LOG_FILE=&quot;${SCRIPT_DIR}/deployment.log&quot;<br>LDAP_HOST=&quot;localhost&quot;<br>ADMIN_PASSWORD=&quot;secret&quot;</pre><pre>log() {<br>    echo -e &quot;[$(date &#39;+%Y-%m-%d %H:%M:%S&#39;)] $1&quot; | tee -a &quot;$LOG_FILE&quot;<br>}</pre><pre>check_dependencies() {<br>    log &quot;🔍 Checking dependencies...&quot;<br>    local missing=()<br>    for cmd in docker docker-compose openssl keytool; do<br>        command -v $cmd &gt;/dev/null 2&gt;&amp;1 || missing+=(&quot;$cmd&quot;)<br>    done<br>    if [ ${#missing[@]} -ne 0 ]; then<br>        log &quot;❌ Missing dependencies: ${missing[*]}&quot;<br>        exit 1<br>    fi<br>    log &quot;✅ Dependencies ok&quot;<br>}</pre><pre>validate_certificates() {<br>    log &quot;🔐 Validating certificate files...&quot;<br>    for file in certs/publiccert.pem certs/privatekey.pem; do<br>        if [ ! -f &quot;$file&quot; ]; then<br>            log &quot;❌ Missing $file&quot; &amp;&amp; exit 1<br>        fi<br>    done<br>    # Certificate format and match<br>    if ! openssl x509 -in certs/publiccert.pem -noout -text &gt;/dev/null; then<br>        log &quot;❌ Invalid certificate&quot; &amp;&amp; exit 1<br>    fi<br>    if ! openssl rsa -in certs/privatekey.pem -check -noout &gt;/dev/null; then<br>        log &quot;❌ Invalid private key&quot; &amp;&amp; exit 1<br>    fi<br>    local cert_md5=$(openssl x509 -noout -modulus -in certs/publiccert.pem | openssl md5)<br>    local key_md5=$(openssl rsa -noout -modulus -in certs/privatekey.pem | openssl md5)<br>    if [[ &quot;$cert_md5&quot; != &quot;$key_md5&quot; ]]; then<br>        log &quot;❌ Certificate and key do not match&quot; &amp;&amp; exit 1<br>    fi<br>    log &quot;✅ Certificate and key are valid&quot;<br>}</pre><pre>create_keystores() {<br>    log &quot;🔑 Creating Java keystores...&quot;<br>    mkdir -p keystores<br>    [ -f keystores/key.p12 ] &amp;&amp; mv keystores/key.p12 keystores/key.p12.bak</pre><pre>    openssl pkcs12 -export \<br>        -in certs/publiccert.pem \<br>        -inkey certs/privatekey.pem \<br>        -out keystores/key.p12 \<br>        -name &quot;dcm4chee&quot; \<br>        -passout pass:secret</pre><pre>    if [ -f certs/ca-chain.pem ]; then<br>        keytool -import -trustcacerts -alias ca-root \<br>            -file certs/ca-chain.pem \<br>            -keystore keystores/cacerts.p12 \<br>            -storetype PKCS12 -storepass secret -noprompt<br>    else<br>        # create empty truststore if no CA<br>        keytool -genkey -alias dummy -keystore keystores/cacerts.p12 \<br>            -storetype PKCS12 -storepass secret \<br>            -dname &quot;CN=dummy&quot; -keypass secret<br>        keytool -delete -alias dummy -keystore keystores/cacerts.p12 -storepass secret<br>    fi</pre><pre>    cp keystores/cacerts.p12 keystores/client-truststore.p12<br>    log &quot;✅ Keystores created&quot;<br>}</pre><pre>start_services() {<br>    log &quot;🚀 Starting services with Docker Compose...&quot;<br>    docker-compose down --remove-orphans &gt;/dev/null 2&gt;&amp;1 || true<br>    docker-compose up -d<br>    sleep 15<br>    # Wait for LDAP readiness<br>    local attempts=0<br>    until docker-compose exec -T ldap ldapsearch -x -H ldap://localhost:389 -b &quot;dc=dcm4che,dc=org&quot; &gt;/dev/null 2&gt;&amp;1; do<br>        sleep 5<br>        ((attempts++))<br>        if [ $attempts -gt 20 ]; then<br>            log &quot;❌ LDAP failed to start&quot; &amp;&amp; exit 1<br>        fi<br>    done<br>    log &quot;✅ Services are up&quot;<br>}</pre><pre>apply_ldap_configuration() {<br>    log &quot;🔧 Applying LDAP configurations...&quot;<br>    sleep 5<br>    # Use host ldapmodify if available, else use container<br>    if command -v ldapmodify &gt;/dev/null; then<br>        info=&quot;Using host ldapmodify&quot;<br>        ldapmodify -x -H ldap://$LDAP_HOST:389 \<br>            -D &quot;cn=admin,dc=dcm4che,dc=org&quot; -w &quot;$ADMIN_PASSWORD&quot; \<br>            -f 01-bcp195-dicom-ciphers.ldif<br>        if [ -f 02-client-cert-auth.ldif ]; then<br>            ldapmodify -x -H ldap://$LDAP_HOST:389 \<br>                -D &quot;cn=admin,dc=dcm4che,dc=org&quot; -w &quot;$ADMIN_PASSWORD&quot; \<br>                -f 02-client-cert-auth.ldif<br>        fi<br>        ldapmodify -x -H ldap://$LDAP_HOST:389 \<br>            -D &quot;cn=admin,dc=dcm4che,dc=org&quot; -w &quot;$ADMIN_PASSWORD&quot; \<br>            -f 03-complete-bcp195-config.ldif<br>    else<br>        docker cp 01-bcp195-dicom-ciphers.ldif $(docker-compose ps -q ldap):/tmp/<br>        docker-compose exec -T ldap ldapmodify -x -H ldap://localhost:389 \<br>            -D &quot;cn=admin,dc=dcm4che,dc=org&quot; -w &quot;$ADMIN_PASSWORD&quot; \<br>            -f /tmp/01-bcp195-dicom-ciphers.ldif<br>        if [ -f 02-client-cert-auth.ldif ]; then<br>            docker cp 02-client-cert-auth.ldif $(docker-compose ps -q ldap):/tmp/<br>            docker-compose exec -T ldap ldapmodify -x -H ldap://localhost:389 \<br>                -D &quot;cn=admin,dc=dcm4che,dc=org&quot; -w &quot;$ADMIN_PASSWORD&quot; \<br>                -f /tmp/02-client-cert-auth.ldif<br>        fi<br>        docker cp 03-complete-bcp195-config.ldif $(docker-compose ps -q ldap):/tmp/<br>        docker-compose exec -T ldap ldapmodify -x -H ldap://localhost:389 \<br>            -D &quot;cn=admin,dc=dcm4che,dc=org&quot; -w &quot;$ADMIN_PASSWORD&quot; \<br>            -f /tmp/03-complete-bcp195-config.ldif<br>    fi</pre><pre>    log &quot;✅ LDAP configurations applied. Restarting DCM4Chee Archive...&quot;<br>    docker-compose restart arc<br>    sleep 15<br>}</pre><pre>verify_compliance() {<br>    log &quot;🔍 Verifying BCP 195 compliance...&quot;<br>    # Test strong cipher connection<br>    result=$(timeout 5 openssl s_client -connect localhost:2762 -cipher &#39;ECDHE-RSA-AES256-GCM-SHA384&#39; -brief 2&gt;/dev/null | grep &quot;Cipher is&quot;)<br>    if [[ &quot;$result&quot; == *&quot;ECDHE-RSA-AES256-GCM-SHA384&quot;* ]]; then<br>        log &quot;✅ Strong cipher ECDHE-RSA-AES256-GCM-SHA384 in use&quot;<br>    else<br>        log &quot;⚠️  Strong cipher test failed (cipher: $result)&quot;<br>    fi<br>    # Test weak cipher rejection<br>    weak=$(timeout 5 openssl s_client -connect localhost:2762 -cipher &#39;AES128-SHA&#39; 2&gt;/dev/null)<br>    if [[ &quot;$weak&quot; == &quot;&quot; || &quot;$weak&quot; == *&quot;no shared cipher&quot;* ]]; then<br>        log &quot;✅ Weak ciphers are rejected&quot;<br>    else<br>        log &quot;⚠️  Weak cipher was not rejected&quot;<br>    fi<br>}</pre><pre>main() {<br>    date &gt;&quot;$LOG_FILE&quot;<br>    check_dependencies<br>    validate_certificates<br>    create_keystores<br>    start_services<br>    apply_ldap_configuration<br>    verify_compliance<br>    log &quot;🎉 Deployment completed successfully!&quot;<br>}</pre><pre>main &quot;$@&quot;</pre><p>This script automates the entire process, including waiting for services and testing the TLS handshake. It logs progress and errors to deployment.log.</p><h3>🧪 Step 6: Testing and Verification</h3><p>After deployment, run the test-bcp195-compliance.sh script (as created below) to automate TLS tests:</p><pre>cat &gt; test-bcp195-compliance.sh &lt;&lt; &#39;EOF&#39;<br>#!/bin/bash<br>echo &quot;🧪 Testing BCP 195 Compliance...&quot;<br>echo &quot;&quot;<br># Strong cipher test<br>echo &quot;Test 1: Strong Cipher Connectivity (ECDHE-RSA-AES256-GCM-SHA384)&quot;<br>if timeout 10 openssl s_client -connect localhost:2762 -cipher &#39;ECDHE-RSA-AES256-GCM-SHA384&#39; -brief 2&gt;/dev/null | grep -q &quot;ECDHE-RSA-AES256-GCM-SHA384&quot;; then<br>    echo &quot;✅ Strong cipher handshake succeeded&quot;<br>else<br>    echo &quot;❌ Strong cipher handshake failed&quot;<br>fi<br>echo &quot;&quot;<br># Weak cipher test<br>echo &quot;Test 2: Weak Cipher Rejection (AES128-SHA)&quot;<br>if timeout 5 openssl s_client -connect localhost:2762 -cipher &#39;AES128-SHA&#39; 2&gt;/dev/null | grep -q &quot;Cipher is&quot;; then<br>    echo &quot;❌ Weak cipher succeeded (SECURITY ISSUE)&quot;<br>else<br>    echo &quot;✅ Weak cipher properly rejected&quot;<br>fi<br>echo &quot;&quot;<br># TLS protocol support<br>echo &quot;Test 3: TLS Protocols&quot;<br>if timeout 10 openssl s_client -connect localhost:2762 -tls1_2 -brief 2&gt;/dev/null | grep -q &quot;Protocol  : TLSv1.2&quot;; then<br>    echo &quot;✅ TLS 1.2 supported&quot;<br>else<br>    echo &quot;❌ TLS 1.2 not supported&quot;<br>fi<br>if timeout 10 openssl s_client -connect localhost:2762 -tls1_3 -brief 2&gt;/dev/null | grep -q &quot;Protocol  : TLSv1.3&quot;; then<br>    echo &quot;✅ TLS 1.3 supported&quot;<br>else<br>    echo &quot;⚠️ TLS 1.3 not supported&quot;<br>fi<br>echo &quot;&quot;<br># Certificate check<br>echo &quot;Test 4: Certificate Info&quot;<br>openssl s_client -connect localhost:2762 -showcerts 2&gt;/dev/null | openssl x509 -noout -subject -issuer -dates<br>echo &quot;&quot;<br>echo &quot;Test 5: Cipher Enumeration (if nmap available)&quot;<br>if command -v nmap &gt;/dev/null 2&gt;&amp;1; then<br>    nmap --script ssl-enum-ciphers -p 2762 localhost | grep -E &quot;(TLS|Cipher|Grade)&quot;<br>else<br>    echo &quot;⚠️ nmap not installed. Manually run: nmap --script ssl-enum-ciphers -p 2762 localhost&quot;<br>fi<br>EOF<br>chmod +x test-bcp195-compliance.sh</pre><p>Run it after deployment:</p><pre>./test-bcp195-compliance.sh</pre><p>It will check that a strong cipher connects successfully, weak ciphers are refused, and list TLS versions and certificate details.</p><h3>📋 Step 7: Complete Deployment Process</h3><h3>7.1 Execute Deployment</h3><pre># Run the full deployment<br>sudo ./deploy-dcm4chee-bcp195.sh</pre><p>This creates keystores, starts containers, applies LDAP config, and verifies TLS. Check the output and deployment.log for success messages.</p><h3>7.2 Verify Installation</h3><pre># Run compliance tests:<br>./test-bcp195-compliance.sh</pre><pre># Confirm containers are running:<br>docker-compose ps</pre><pre># View recent Archive logs:<br>docker-compose logs arc | tail -n 20</pre><p>All services (LDAP, PostgreSQL, Archive) should be up. Ensure the Archive’s log shows “SSL” or “keystore” messages without errors.</p><h3>7.3 Manual Verification</h3><pre># Test Web UI (self-signed cert might need -k):<br>curl -k https://localhost:8443/dcm4chee-arc/ui2/ | grep -q &quot;dcm4chee&quot; &amp;&amp; echo &quot;✅ UI is up&quot; || echo &quot;❌ UI problem&quot;</pre><pre># Test DICOM TLS handshake:<br>openssl s_client -connect localhost:2762 -brief | grep &quot;Cipher is&quot;</pre><pre># Check LDAP device config:<br>docker-compose exec ldap ldapsearch -x -H ldap://localhost:389 \<br>  -b &quot;cn=dicom,ou=Devices,dc=dcm4che,dc=org&quot; \<br>  dcmTLSCipherSuite dcmTLSProtocol dcmKeyStoreURL</pre><p>The LDAP query should show your BCP 195 cipher suite lines and dcmTLSProtocol: TLSv1.2, TLSv1.3 entries. The DICOM TLS handshake should report one of the strong ciphers (e.g. Cipher is ECDHE-RSA-AES256-GCM-SHA384).</p><h3>🔧 Step 8: Maintenance and Monitoring</h3><p>Maintain compliance by periodically testing and renewing certs:</p><h3>8.1 Monitoring Script</h3><pre>cat &gt; monitor-bcp195.sh &lt;&lt; &#39;EOF&#39;<br>#!/bin/bash<br>LOG_FILE=&quot;bcp195-monitor.log&quot;<br>timestamp() { date &#39;+%Y-%m-%d %H:%M:%S&#39;; }</pre><pre># Check current cipher<br>cipher=$(timeout 5 openssl s_client -connect localhost:2762 2&gt;/dev/null | grep &quot;Cipher is&quot; | awk &#39;{print $3}&#39;)<br>echo &quot;[$(timestamp)] Cipher in use: $cipher&quot; | tee -a $LOG_FILE</pre><pre># Evaluate compliance<br>if [[ &quot;$cipher&quot; == *&quot;AES256-GCM&quot;* ]] || [[ &quot;$cipher&quot; == *&quot;AES128-GCM&quot;* ]] || [[ &quot;$cipher&quot; == *&quot;CHACHA20&quot;* ]]; then<br>    echo &quot;[$(timestamp)] ✅ Cipher $cipher is BCP195-compliant&quot; | tee -a $LOG_FILE<br>else<br>    echo &quot;[$(timestamp)] ❌ Cipher $cipher is NOT compliant&quot; | tee -a $LOG_FILE<br>fi</pre><pre># Check cert expiration<br>expiry=$(openssl x509 -in certs/publiccert.pem -noout -enddate | cut -d= -f2)<br>days=$(( ($(date -d &quot;$expiry&quot; +%s) - $(date +%s)) / 86400 ))<br>if [ $days -lt 30 ]; then<br>    echo &quot;[$(timestamp)] ⚠️ Certificate expires in $days days&quot; | tee -a $LOG_FILE<br>fi<br>EOF<br>chmod +x monitor-bcp195.sh</pre><p>Run this periodically (e.g. via cron) to log current cipher and certificate expiry. It alerts if a non-BCP195 cipher appears or if the cert is expiring soon.</p><h3>8.2 Automated Monitoring</h3><p>Add to crontab (runs every 30 minutes):</p><pre>(crontab -l 2&gt;/dev/null; echo &quot;*/30 * * * * $(pwd)/monitor-bcp195.sh&quot;) | crontab -</pre><h3>🚨 Troubleshooting</h3><p><strong>Certificate/Key Mismatch</strong>: Re-run the modulus check from Step 1.3. They must be identical.</p><p><strong>LDAP Connection Failed</strong>: Ensure the dcm4che/slapd-dcm4chee container is healthy. Logs can be checked with docker-compose logs ldap. Remember the default LDAP admin password is secret (matching our script).</p><p><strong>Weak Ciphers Still Active</strong>: If AES128-SHA etc. still work, double-check that the LDIF applied correctly. You can force re-import:</p><ul><li>docker-compose down docker volume prune -f ./deploy-dcm4chee-bcp195.sh</li></ul><p><strong>Archive Won’t Start</strong>: Inspect WildFly logs:</p><p>docker-compose logs arc | grep -i error</p><p>Look for Keystore errors or port conflicts. Confirm ports 2762/8443 are free (sudo netstat -tulpn).</p><h3>📊 Performance Considerations</h3><p>Enabling stronger ciphers adds minor overhead, but on modern servers it’s negligible. Rough benchmarks:</p><p><strong>CPU Overhead</strong>: +5–10% under load (ECDHE key exchange is slightly heavier).</p><p><strong>Memory</strong>: +1–2% (no material change).</p><p><strong>Latency/Throughput</strong>: Handshake latency +2–5ms, throughput drop ~2–5% (acceptable trade-off for security).</p><p><strong>Optimization Tips</strong>:</p><p>Tune JVM heap (-Xms/Xmx) for your workload.</p><p>Enable TLS session caching in WildFly: -Djavax.net.ssl.sessionCacheSize=500.</p><h3>🔄 Backup and Recovery</h3><p>Script to back up configs and data:</p><pre>cat &gt; backup-dcm4chee.sh &lt;&lt; &#39;EOF&#39;<br>#!/bin/bash<br>BACKUP_DIR=&quot;backups/$(date +%Y%m%d_%H%M%S)&quot;<br>mkdir -p &quot;$BACKUP_DIR&quot;<br>echo &quot;🔄 Creating backup...&quot;</pre><pre># Backup configs and LDIFs<br>cp -r certs &quot;$BACKUP_DIR/&quot;<br>cp -r keystores &quot;$BACKUP_DIR/&quot;<br>cp *.ldif &quot;$BACKUP_DIR/&quot;<br>cp docker-compose.yml docker-compose.env &quot;$BACKUP_DIR/&quot;</pre><pre># Backup database<br>docker-compose exec -T db pg_dump -U pacs pacsdb &gt; &quot;$BACKUP_DIR/pacsdb.sql&quot;</pre><pre># Backup LDAP<br>docker-compose exec -T ldap slapcat &gt; &quot;$BACKUP_DIR/ldap-backup.ldif&quot;</pre><pre>echo &quot;✅ Backup saved to $BACKUP_DIR&quot;<br>EOF<br>chmod +x backup-dcm4chee.sh</pre><p>Run ./backup-dcm4chee.sh periodically. This captures certs, configs, DB dump, and LDAP content.</p><h3>🎯 Summary</h3><p>By following these steps, you now have a <strong>production-ready DCM4Chee deployment</strong> with full DICOM BCP 195 compliance. Key points:</p><p><strong>Certificate Management</strong>: Converted any certificate (PEM/PFX/etc.) into PKCS12 keystores (private key + cert) as require</p><p><strong>Strong Ciphers</strong>: Restricted to ECDHE/DHE with AES-GCM or ChaCha20; disabled outdated ciphers, per DICOM BCP 195</p><p><strong>Four-Layer Enforcement</strong>: Configured ciphers at (a) Environment (WildFly TLS settings), (b) JVM (system properties), © WildFly/Elytron (cipher filters), and (d) LDAP device entries (dcmTLSCipherSuite).</p><p><strong>Automated Deployment</strong>: One script (deploy-dcm4chee-bcp195.sh) for all steps, plus validation and error-checking.</p><p><strong>Testing &amp; Monitoring</strong>: Provided scripts for compliance testing and ongoing monitoring of ciphers and cert expiry.</p><p><strong>Troubleshooting Tips</strong>: Common pitfalls (LDAP errors, key mismatches) and remedies are documented above.</p><p><strong>Quick Command Reference</strong>:</p><pre># Deploy DCM4Chee with BCP 195<br>./deploy-dcm4chee-bcp195.sh</pre><pre># Run compliance tests<br>./test-bcp195-compliance.sh</pre><pre># Monitor compliance<br>./monitor-bcp195.sh</pre><pre># Backup everything<br>./backup-dcm4chee.sh</pre><pre># Check running containers<br>docker-compose ps</pre><pre># View latest logs<br>docker-compose logs arc | tail -n 20</pre><p>This fully automated process ensures that DCM4Chee’s DICOM connections use <strong>TLS 1.2+ with only BCP195-approved ciphers</strong>, satisfying current healthcare IT security standards</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50882159da0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Markdown Uploads to S3 & Bedrock Knowledge Base Sync with GitHub Actions/Jenkins/Gitlab]]></title>
            <link>https://medium.com/@praveen.valaboju1/automating-markdown-uploads-to-s3-bedrock-knowledge-base-sync-with-github-actions-7ca980b8ef7f?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ca980b8ef7f</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[amazon-bedrock]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 06:52:52 GMT</pubDate>
            <atom:updated>2025-07-21T06:53:42.097Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>By Praveen Valaboju</strong> | <em>DevOps | AWS | Bedrock | GitHub Actions | AI-Driven Knowledge Bases</em></p><p>Modern development workflows thrive on automation, transparency, and intelligent documentation. At Hackathon scale — or even in enterprise production — you need pipelines that not only ship code but also <strong>synchronize your content</strong> into AI-ready knowledge systems. That’s exactly what this GitHub Actions workflow does.</p><p>In this post, I’ll walk through a powerful automation I created: a <strong>GitHub Actions workflow that uploads Markdown documentation to Amazon S3</strong>, triggers a <strong>Bedrock Knowledge Base ingestion job</strong>, and sends a <strong>completion summary email</strong> using SMTP. It’s clean, scalable, and GenAI-ready.</p><h3>What This Workflow Solves</h3><blockquote><em>✅ Automatically uploads </em><em>.md documentation files from a GitHub repository<br> ✅ Syncs those files with Amazon Bedrock Knowledge Base<br> ✅ Sends a completion report via email<br> ✅ Built-in visibility, accountability, and reusability</em></blockquote><p>This is ideal for:</p><p>Hackathon or internal KB sync automation</p><p>GenAI context engineering with Markdown content</p><p>Triggering RAG workflows on AWS Bedrock</p><p>Enabling CI/CD for your documentation lifecycle</p><h3>Workflow Trigger</h3><p>The pipeline runs:</p><p>On push to main for Markdown files or workflow updates</p><p>Manually via workflow_dispatch</p><pre>on:<br>  push:<br>    branches: [ &#39;main&#39; ]<br>    paths: <br>      - &#39;.github/workflows/main.yml&#39;<br>      - &#39;docs/**/*.md&#39;<br>  workflow_dispatch:</pre><p>Environment Variables &amp; AWS Context</p><p>Key context:</p><p>Markdown files are uploaded to an S3 bucket named hackathonkb</p><p>Uploads are versioned by GitHub repository name</p><p>AWS credentials and Bedrock IDs are securely passed using GitHub vars and secrets</p><pre>env:<br>  REPO_NAME: ${{ github.event.repository.name }} <br>  AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}<br>  S3_BUCKET: hackathonkb<br>  BEDROCK_KNOWLEDGE_BASE_ID: ${{ vars.BEDROCK_KNOWLEDGE_BASE_ID }}<br>  BEDROCK_DATA_SOURCE_ID: ${{ vars.BEDROCK_DATA_SOURCE_ID }}</pre><p>Job Breakdown</p><ol><li>Checkout &amp; Scan for Markdown</li></ol><pre>find . -name &quot;*.md&quot; -type f &gt; md_files_list.txt</pre><p>2. Configure AWS &amp; Upload Files to S3</p><p>Using aws-actions/configure-aws-credentials, the workflow assumes a secure IAM role to access S3:</p><pre>role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/${{ vars.ENVIRONMENT }}-role-devops</pre><p>Then each markdown file is uploaded with custom metadata:</p><pre>aws s3 cp &quot;$file&quot; &quot;s3://hackathonkb/${REPO_NAME}/$clean_path&quot; --content-type &quot;text/markdown&quot;</pre><p>3. Trigger Bedrock Knowledge Base Sync</p><p>Once uploaded, the pipeline invokes an ingestion job to sync the content into Amazon Bedrock:</p><pre>aws bedrock-agent start-ingestion-job \<br>  --knowledge-base-id $BEDROCK_KNOWLEDGE_BASE_ID \<br>  --data-source-id $BEDROCK_DATA_SOURCE_ID</pre><p>This enables the content to be used for RAG (retrieval-augmented generation) in future GenAI use cases.</p><p>4. SMTP Email Notification</p><p>Using the <a href="https://github.com/wadeww/send-email-action">wadeww/send-email-action</a>, a summary email is dispatched with repository details, file count, and S3 location:</p><pre>subject: &quot;[HackathonKB] Sync Completed for ${{ env.REPO_NAME }}&quot;</pre><p>It also verifies presence of all email-related secrets for fail-safe ops.</p><p>Summary Output Example</p><p>Here’s what the summary looks like:</p><p>✅ S3 Bucket knowledge base sync is complete!</p><p>📘 Repository: my-ai-docs<br>📝 Markdown Files: 12<br>📁 Content: s3://&lt;Bucket Name&gt;/my-ai-docs/<br>🤖 Knowledge Base ID: kb-xyz<br>📡 Data Source ID: ds-abc</p><h3>Why It Matters</h3><p><strong>Seamless Content-to-AI Flow</strong><br> From GitHub to Bedrock — fully automated.</p><p><strong>Ready for RA</strong>G<br> Your markdown content becomes fuel for intelligent applications.</p><p><strong>Secure by Desig</strong>n<br> IAM Role assumption via OIDC, no long-term credentials.</p><p><strong>Built-in Reporting</strong><br> Get notified when your content is live and searchable.</p><p>#######################Github Actions #######################</p><pre>name: MarkdownUpload<br><br>on:<br>  push:<br>    branches: [ &#39;main&#39; ]<br>    paths: <br>      - &#39;.github/workflows/main.yml&#39;<br>      - &#39;docs/**/*.md&#39;<br>  workflow_dispatch:<br><br>env:<br>  REPO_NAME: ${{ github.event.repository.name }} <br>  ENVIRONMENT: ${{ vars.ENVIRONMENT }}                         # e.g., &quot;dev&quot;, &quot;prod&quot;<br>  AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}                   # e.g., &quot;123456789012&quot;<br>  S3_BUCKET: your-s3-bucket-name                               # e.g., &quot;my-docs-kb&quot;<br>  BEDROCK_KNOWLEDGE_BASE_ID: ${{ vars.BEDROCK_KNOWLEDGE_BASE_ID }}<br>  BEDROCK_DATA_SOURCE_ID: ${{ vars.BEDROCK_DATA_SOURCE_ID }}<br><br>permissions:<br>  id-token: write<br>  contents: read<br><br>jobs:<br>  upload-markdown-files:<br>    runs-on: ubuntu-latest<br>    environment: ${{ env.ENVIRONMENT }}<br>    permissions:<br>      contents: read<br>      id-token: write<br><br>    steps:<br>      - name: Checkout Repository<br>        uses: actions/checkout@v3<br><br>      - name: Find and List Markdown Files<br>        id: find-md<br>        run: |<br>          find . -name &quot;*.md&quot; -type f &gt; md_files_list.txt<br>          echo &quot;md_count=$(wc -l &lt; md_files_list.txt)&quot; &gt;&gt; &quot;$GITHUB_OUTPUT&quot;<br><br>      - name: Prepare Markdown Content for Upload<br>        run: |<br>          while IFS= read -r file; do<br>            if [ -f &quot;$file&quot; ]; then<br>              clean_path=${file#./}<br>              echo &quot;Processing: $clean_path&quot;<br>            fi<br>          done &lt; md_files_list.txt<br><br>      - name: Configure AWS Credentials<br>        uses: aws-actions/configure-aws-credentials@v4<br>        with:<br>          aws-region: your-aws-region                            # e.g., &quot;us-west-2&quot;<br>          role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/${{ env.ENVIRONMENT }}-role-devops<br>          role-session-name: MarkdownUploadSession<br><br>      - name: Upload Markdown Files to S3<br>        run: |<br>          while IFS= read -r file; do<br>            if [ -f &quot;$file&quot; ]; then<br>              clean_path=${file#./}<br>              aws s3 cp &quot;$file&quot; &quot;s3://${{ env.S3_BUCKET }}/${{ env.REPO_NAME }}/$clean_path&quot; \<br>                --content-type &quot;text/markdown&quot; \<br>                --metadata &quot;repo=${{ env.REPO_NAME }},source=docs&quot;<br>              echo &quot;Uploaded: $clean_path&quot;<br>            fi<br>          done &lt; md_files_list.txt<br><br>      - name: Generate Upload Summary<br>        run: |<br>          echo &quot;## Upload Summary&quot;<br>          echo &quot;Repository: ${{ env.REPO_NAME }}&quot;<br>          echo &quot;Total Files: ${{ steps.find-md.outputs.md_count }}&quot;<br>          echo &quot;S3 Path: s3://${{ env.S3_BUCKET }}/${{ env.REPO_NAME }}/&quot;<br>          echo &quot;&quot;<br>          echo &quot;Uploaded Files:&quot;<br>          cat md_files_list.txt | sed &#39;s/^/- /&#39;<br><br>      - name: Trigger Bedrock Knowledge Base Sync<br>        run: |<br>          aws bedrock-agent start-ingestion-job \<br>            --knowledge-base-id &quot;${{ env.BEDROCK_KNOWLEDGE_BASE_ID }}&quot; \<br>            --data-source-id &quot;${{ env.BEDROCK_DATA_SOURCE_ID }}&quot; \<br>            --region your-aws-region                             # e.g., &quot;us-west-2&quot;<br><br>      - name: Send Notification Email (SMTP)<br>        uses: wadeww/send-email-action@v1<br>        with:<br>          server_address: ${{ secrets.EMAIL_SMTP_SERVER }}<br>          port: ${{ secrets.EMAIL_SMTP_PORT }}<br>          username: ${{ secrets.SMTP_USERNAME }}<br>          password: ${{ secrets.EMAIL_PASSWORD }}<br>          from: ${{ secrets.EMAIL_FROM_ADDRESS }}<br>          to: ${{ secrets.EMAIL_TO_ADDRESS }}<br>          subject: &quot;[Knowledge Base] Upload Completed: ${{ env.REPO_NAME }}&quot;<br>          body: |<br>            ✅ Markdown upload complete.<br><br>            📘 Repository: ${{ env.REPO_NAME }}<br>            📝 Total Markdown Files: ${{ steps.find-md.outputs.md_count }}<br>            📁 S3 Location: s3://${{ env.S3_BUCKET }}/${{ env.REPO_NAME }}/<br>            🤖 Bedrock Knowledge Base: ${{ env.BEDROCK_KNOWLEDGE_BASE_ID }}<br><br>            Regards,  <br>            Automation Team<br><br>      - name: Validate SMTP Secrets<br>        if: always()<br>        run: |<br>          for key in EMAIL_SMTP_SERVER EMAIL_SMTP_PORT SMTP_USERNAME EMAIL_PASSWORD EMAIL_FROM_ADDRESS; do<br>            if [ -n &quot;${{ secrets[$key] }}&quot; ]; then echo &quot;✅ $key is set&quot;; else echo &quot;❌ $key is missing&quot;; fi<br>          done</pre><h3>Replace the placeholders:</h3><p>your-s3-bucket-name → your actual S3 bucket name</p><p>your-aws-region → e.g., us-west-2</p><p>#########################Jenkins ###############</p><p><strong>Jenkinsfile (Declarative Pipeline)</strong></p><pre>pipeline {<br>  agent any<br><br>  environment {<br>    REPO_NAME = &quot;${env.JOB_NAME}&quot;<br>    ENVIRONMENT = credentials(&#39;jenkins_env&#39;)              // e.g., &#39;dev&#39;, stored as a credential<br>    AWS_REGION = &#39;us-west-2&#39;<br>    AWS_ACCOUNT_ID = credentials(&#39;aws_account_id&#39;)        // stored credential ID<br>    S3_BUCKET = &#39;your-s3-bucket-name&#39;<br>    BEDROCK_KB_ID = credentials(&#39;bedrock_kb_id&#39;)<br>    BEDROCK_DS_ID = credentials(&#39;bedrock_ds_id&#39;)<br><br>    SMTP_SERVER = credentials(&#39;smtp_server&#39;)<br>    SMTP_PORT = credentials(&#39;smtp_port&#39;)<br>    SMTP_USERNAME = credentials(&#39;smtp_username&#39;)<br>    SMTP_PASSWORD = credentials(&#39;smtp_password&#39;)<br>    EMAIL_FROM = credentials(&#39;smtp_from_address&#39;)<br>    EMAIL_TO = credentials(&#39;smtp_to_address&#39;)<br>  }<br><br>  options {<br>    skipStagesAfterUnstable()<br>  }<br><br>  triggers {<br>    pollSCM(&#39;H/5 * * * *&#39;)  // Optional: polling trigger for changes to markdown<br>  }<br><br>  stages {<br>    stage(&#39;Checkout&#39;) {<br>      steps {<br>        checkout scm<br>      }<br>    }<br><br>    stage(&#39;Find Markdown Files&#39;) {<br>      steps {<br>        script {<br>          echo &quot;🔍 Scanning for Markdown files...&quot;<br>          sh &#39;find . -name &quot;*.md&quot; -type f &gt; md_files_list.txt&#39;<br>          def count = sh(script: &quot;wc -l &lt; md_files_list.txt&quot;, returnStdout: true).trim()<br>          env.MD_COUNT = count<br>          echo &quot;📄 Found ${env.MD_COUNT} markdown files.&quot;<br>        }<br>      }<br>    }<br><br>    stage(&#39;Configure AWS CLI&#39;) {<br>      steps {<br>        withCredentials([[<br>          $class: &#39;AmazonWebServicesCredentialsBinding&#39;,<br>          credentialsId: &#39;aws-creds-id&#39;  // Replace with your Jenkins AWS credentials ID<br>        ]]) {<br>          sh &#39;&#39;&#39;<br>            aws configure set region $AWS_REGION<br>            aws sts get-caller-identity<br>          &#39;&#39;&#39;<br>        }<br>      }<br>    }<br><br>    stage(&#39;Upload to S3&#39;) {<br>      steps {<br>        script {<br>          sh &quot;&quot;&quot;<br>            while IFS= read -r file; do<br>              if [ -f &quot;\$file&quot; ]; then<br>                clean_path=\${file#./}<br>                aws s3 cp &quot;\$file&quot; &quot;s3://$S3_BUCKET/$REPO_NAME/\$clean_path&quot; \<br>                  --content-type &quot;text/markdown&quot; \<br>                  --metadata &quot;repo=$REPO_NAME,source=jenkins-docs&quot;<br>                echo &quot;✅ Uploaded: \$clean_path&quot;<br>              fi<br>            done &lt; md_files_list.txt<br>          &quot;&quot;&quot;<br>        }<br>      }<br>    }<br><br>    stage(&#39;Start Bedrock KB Ingestion&#39;) {<br>      steps {<br>        sh &quot;&quot;&quot;<br>          echo &quot;🔄 Triggering Bedrock ingestion...&quot;<br>          aws bedrock-agent start-ingestion-job \<br>            --knowledge-base-id &quot;$BEDROCK_KB_ID&quot; \<br>            --data-source-id &quot;$BEDROCK_DS_ID&quot; \<br>            --region &quot;$AWS_REGION&quot;<br>        &quot;&quot;&quot;<br>      }<br>    }<br><br>    stage(&#39;Email Notification&#39;) {<br>      steps {<br>        script {<br>          def body = &quot;&quot;&quot;<br>            ✅ Hackathon knowledge base sync is complete!<br><br>            📘 Repository: ${REPO_NAME}<br>            📝 Markdown Files: ${env.MD_COUNT}<br>            📁 S3 Location: s3://${S3_BUCKET}/${REPO_NAME}/<br>            🤖 Knowledge Base ID: ${BEDROCK_KB_ID}<br>            📡 Data Source ID: ${BEDROCK_DS_ID}<br><br>            Regards,<br>            Jenkins Automation<br>          &quot;&quot;&quot;<br><br>          emailext (<br>            subject: &quot;[KnowledgeBase] Sync Completed for ${REPO_NAME}&quot;,<br>            body: body,<br>            to: &quot;${EMAIL_TO}&quot;,<br>            from: &quot;${EMAIL_FROM}&quot;,<br>            mimeType: &#39;text/plain&#39;,<br>            smtpHost: &quot;${SMTP_SERVER}&quot;,<br>            smtpPort: &quot;${SMTP_PORT}&quot;,<br>            replyTo: &quot;${EMAIL_FROM}&quot;,<br>            charset: &#39;UTF-8&#39;,<br>            smtpUsername: &quot;${SMTP_USERNAME}&quot;,<br>            smtpPassword: &quot;${SMTP_PASSWORD}&quot;,<br>            useSsl: false<br>          )<br>        }<br>      }<br>    }<br>  }<br><br>  post {<br>    failure {<br>      mail to: &quot;${EMAIL_TO}&quot;,<br>           subject: &quot;[Jenkins] ❌ Sync Failed for ${REPO_NAME}&quot;,<br>           body: &quot;The Markdown sync job failed. Please check Jenkins logs.&quot;<br>    }<br>  }<br>}</pre><h3>Jenkins Requirements:</h3><p><strong>Credentials Configuration:</strong></p><p>Add the following credentials in Jenkins:</p><p>aws-creds-id: AWS access key ID and secret</p><p>jenkins_env: String credential (e.g., &quot;dev&quot;)</p><p>aws_account_id, bedrock_kb_id, bedrock_ds_id: String credentials</p><p>SMTP credentials as shown (smtp_server, smtp_username, etc.)</p><p><strong>Plugins Required:</strong></p><p><strong>Amazon EC2 plugin</strong> (or AWS CLI configured on the Jenkins agent)</p><p><strong>Email Extension Plugin</strong></p><p><strong>Credentials Binding Plugin</strong></p><p><strong>Jenkins Agent Setup:</strong></p><p>Ensure aws-cli is installed</p><p>Set up IAM roles or access keys securely.</p><p>####################################GITLAB ##################</p><p><strong>Gitlab File</strong></p><pre>stages:<br>  - scan<br>  - upload<br>  - sync<br>  - notify<br><br>variables:<br>  AWS_REGION: &quot;us-west-2&quot;<br>  S3_BUCKET: &quot;your-s3-bucket-name&quot;                          # replace with actual bucket<br>  REPO_NAME: &quot;$CI_PROJECT_NAME&quot;<br>  CLEAN_BRANCH: &quot;${CI_COMMIT_REF_NAME//\//-}&quot;<br><br>scan_markdown:<br>  stage: scan<br>  script:<br>    - echo &quot;🔍 Scanning for markdown files...&quot;<br>    - find . -name &quot;*.md&quot; -type f &gt; md_files_list.txt<br>    - cat md_files_list.txt<br>    - echo &quot;MD_COUNT=$(wc -l &lt; md_files_list.txt)&quot; &gt;&gt; variables.env<br>  artifacts:<br>    paths:<br>      - md_files_list.txt<br>      - variables.env<br><br>upload_to_s3:<br>  stage: upload<br>  image: amazon/aws-cli<br>  dependencies:<br>    - scan_markdown<br>  script:<br>    - source variables.env<br>    - echo &quot;🔑 Configuring AWS CLI&quot;<br>    - aws configure set region $AWS_REGION<br>    - |<br>      while IFS= read -r file; do<br>        if [ -f &quot;$file&quot; ]; then<br>          clean_path=${file#./}<br>          echo &quot;Uploading: $clean_path&quot;<br>          aws s3 cp &quot;$file&quot; &quot;s3://${S3_BUCKET}/${REPO_NAME}/$clean_path&quot; \<br>            --content-type &quot;text/markdown&quot; \<br>            --metadata &quot;repo=$REPO_NAME,source=gitlab-docs&quot;<br>        fi<br>      done &lt; md_files_list.txt<br>  rules:<br>    - changes:<br>        - docs/**/*.md<br>    - exists:<br>        - .gitlab-ci.yml<br><br>trigger_bedrock_ingestion:<br>  stage: sync<br>  image: amazon/aws-cli<br>  dependencies:<br>    - upload_to_s3<br>  script:<br>    - source variables.env<br>    - echo &quot;📡 Triggering Bedrock Ingestion Job&quot;<br>    - aws bedrock-agent start-ingestion-job \<br>        --knowledge-base-id &quot;$BEDROCK_KB_ID&quot; \<br>        --data-source-id &quot;$BEDROCK_DS_ID&quot; \<br>        --region &quot;$AWS_REGION&quot;<br>  rules:<br>    - if: &#39;$CI_PIPELINE_SOURCE == &quot;push&quot;&#39;<br><br>send_email_notification:<br>  stage: notify<br>  image: python:3.9<br>  dependencies:<br>    - scan_markdown<br>  script:<br>    - pip install secure-smtplib<br>    - source variables.env<br>    - |<br>      python3 - &lt;&lt;EOF<br>      import smtplib<br>      from email.mime.text import MIMEText<br><br>      body = f&quot;&quot;&quot;<br>      ✅ Hackathon knowledge base sync is complete!<br><br>      📘 Repository: {os.environ[&#39;REPO_NAME&#39;]}<br>      📝 Markdown Files: {os.environ[&#39;MD_COUNT&#39;]}<br>      📁 S3 Location: s3://{os.environ[&#39;S3_BUCKET&#39;]}/{os.environ[&#39;REPO_NAME&#39;]}/<br>      🤖 Knowledge Base ID: {os.environ[&#39;BEDROCK_KB_ID&#39;]}<br>      📡 Data Source ID: {os.environ[&#39;BEDROCK_DS_ID&#39;]}<br>      &quot;&quot;&quot;<br><br>      msg = MIMEText(body)<br>      msg[&#39;Subject&#39;] = f&quot;[KnowledgeBase] Sync Completed for {os.environ[&#39;REPO_NAME&#39;]}&quot;<br>      msg[&#39;From&#39;] = os.environ[&#39;EMAIL_FROM&#39;]<br>      msg[&#39;To&#39;] = os.environ[&#39;EMAIL_TO&#39;]<br><br>      with smtplib.SMTP(os.environ[&#39;SMTP_SERVER&#39;], int(os.environ[&#39;SMTP_PORT&#39;])) as server:<br>          server.login(os.environ[&#39;SMTP_USERNAME&#39;], os.environ[&#39;SMTP_PASSWORD&#39;])<br>          server.send_message(msg)<br>      EOF<br>  rules:<br>    - when: always<br><br></pre><h3>Required GitLab CI/CD Configuration</h3><p>To successfully execute the GitLab pipeline, you must configure several environment variables in your project. Navigate to <strong>GitLab → Settings → CI/CD → Variables</strong> and add the following:</p><p><strong>AWS_ACCESS_KEY_ID</strong> and <strong>AWS_SECRET_ACCESS_KEY</strong> should be added as <strong>masked variables</strong>. These are your AWS credentials used to authenticate with the AWS CLI for uploading files to S3 and triggering Bedrock operations.</p><p><strong>BEDROCK_KB_ID</strong> and <strong>BEDROCK_DS_ID</strong> are standard variables (not masked) representing your Amazon Bedrock Knowledge Base ID and Data Source ID, respectively. These are required for starting the ingestion job.</p><p><strong>SMTP_SERVER</strong> and <strong>SMTP_PORT</strong> are standard variables that define your outgoing mail server. For example, use smtp.sendgrid.net or smtp.office365.com as the server, and typically 587 for the port.</p><p><strong>SMTP_USERNAME</strong> and <strong>SMTP_PASSWORD</strong> should be added as <strong>masked variables</strong>. These credentials are used to authenticate with the SMTP server when sending notification emails.</p><p><strong>EMAIL_FROM</strong> and <strong>EMAIL_TO</strong> are standard variables that define the sender and recipient email addresses for the completion notification. Use your organization or team address for the sender (e.g., noreply@yourdomain.com) and your personal or team inbox for the recipient (e.g., you@yourdomain.com).</p><p>Ensure that the <strong>masked variables</strong> are marked appropriately in GitLab to avoid exposing sensitive information in pipeline logs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ca980b8ef7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Amazon Bedrock Knowledge Base from S3 with Indexing Constraints (≤49MB per File)]]></title>
            <link>https://medium.com/@praveen.valaboju1/building-an-amazon-bedrock-knowledge-base-from-s3-with-indexing-constraints-49mb-per-file-4cb58687b8e9?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cb58687b8e9</guid>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Thu, 17 Jul 2025 04:42:12 GMT</pubDate>
            <atom:updated>2025-07-17T14:28:31.846Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>Amazon Bedrock provides access to powerful foundation models through a fully managed service. One of its key features is the <strong>Knowledge Base</strong>, which enables <strong>context-aware retrieval-augmented generation (RAG)</strong> — allowing you to ground your generative AI models with your own data.</p><p>This article explains how to:</p><ul><li>Create a Knowledge Base in <strong>Amazon Bedrock</strong> using an <strong>S3 bucket</strong> as the data source</li><li>Ensure uploaded files are within the <strong>49MB limit</strong>, avoiding indexing failures</li><li>Explore the <strong>benefits of using Knowledge Bases</strong> for context engineering and enterprise GenAI systems</li></ul><h3>What is a Bedrock Knowledge Base?</h3><p>A <strong>Knowledge Base (KB)</strong> in Amazon Bedrock:</p><ul><li>Connects to a <strong>data source</strong> like Amazon S3</li><li>Indexes your documents using an <strong>embedding model</strong></li><li>Enables <strong>semantic search and retrieval</strong>, enhancing responses from foundation models with <strong>accurate, private data</strong></li></ul><p>It is essential for <strong>context engineering</strong> — where custom enterprise data improves model outputs for customer support, legal advice, product documentation, and more.</p><h3>Step-by-Step: Create a Bedrock Knowledge Base using S3</h3><h3>🔹 1. Prepare Your Documents</h3><ul><li>Format: .pdf, .txt, .csv, .docx, etc.</li><li>Size: Each file must be <strong>≤49MB</strong>. Bedrock currently does not index files larger than this limit.</li></ul><p><strong>Tip</strong>: Split large documents using tools like PyPDF2, pdftk, or Ghostscript.</p><p><strong>Python example to split PDFs:</strong></p><pre>from PyPDF2 import PdfReader, PdfWriter<br><br>def split_pdf(input_path, max_pages_per_chunk=20):<br>    reader = PdfReader(input_path)<br>    for i in range(0, len(reader.pages), max_pages_per_chunk):<br>        writer = PdfWriter()<br>        for j in range(i, min(i + max_pages_per_chunk, len(reader.pages))):<br>            writer.add_page(reader.pages[j])<br>        output_filename = f&quot;output_chunk_{i // max_pages_per_chunk + 1}.pdf&quot;<br>        with open(output_filename, &quot;wb&quot;) as f_out:<br>            writer.write(f_out)<br>        print(f&quot;Created: {output_filename}&quot;)</pre><p><strong>How to use:</strong></p><ul><li>Save the script as split_pdf.py</li><li>Run it with a large PDF file:</li></ul><pre>python split_pdf.py</pre><p>Adjust max_pages_per_chunk as needed to keep each output file under 49MB.</p><h3>2. Upload Documents to an S3 Bucket</h3><ul><li>Create a bucket (e.g., my-bedrock-kb-data)</li><li>Upload your files under a prefix/folder (e.g., docs/)</li></ul><h3>3. Create an IAM Role</h3><p>Assign the following permissions to a role trusted by <strong>Bedrock</strong>:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: [<br>    &quot;s3:GetObject&quot;,<br>    &quot;s3:ListBucket&quot;<br>  ],<br>  &quot;Resource&quot;: [<br>    &quot;arn:aws:s3:::my-bedrock-kb-data&quot;,<br>    &quot;arn:aws:s3:::my-bedrock-kb-data/*&quot;<br>  ]<br>}</pre><p>Also add:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Action&quot;: &quot;bedrock:*&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><h3>4. Create the Knowledge Base in AWS Console</h3><p>1.Navigate to <strong>Amazon Bedrock &gt; Knowledge Bases</strong></p><p>2. Click <strong>Create Knowledge Base</strong></p><p>3.Provide:</p><ul><li><strong>Name</strong> (e.g., EnterpriseDocsKB)</li><li><strong>Embedding Model</strong> (e.g., cohere.embed-english-v3)</li><li><strong>Data Source</strong>: Amazon S3</li><li><strong>S3 URI</strong>: e.g., s3://my-bedrock-kb-data/docs/</li><li><strong>IAM Role</strong>: Select the one created earlier</li></ul><p>Click <strong>Create</strong></p><p>Bedrock will <strong>ingest and index</strong> all valid files ≤49MB automatically.</p><h3>5. Query the Knowledge Base via Console or SDK</h3><ul><li>Use the <strong>Bedrock Console</strong> to test your KB with natural language prompts</li><li>Integrate with your app using <strong>AWS SDK</strong> to enable <strong>RAG (Retrieval-Augmented Generation)</strong></li></ul><h3>Why Use a Knowledge Base for Context Engineering?</h3><p>Traditional LLMs do not have your company’s data. With Bedrock KB, you can:</p><p>✅ Reduce hallucinations<br> ✅ Improve accuracy with domain-specific knowledge<br> ✅ Ensure regulatory compliance (HIPAA, GDPR, etc.)<br> ✅ Power AI agents with internal documents and manuals<br> ✅ Automate enterprise support and knowledge delivery</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*39u3eN-xVhCMUKJ7VhPILA.png" /></figure><h3>Final Thoughts</h3><p>Amazon Bedrock Knowledge Bases are a game-changer for <strong>context-rich AI systems</strong>. By indexing your organization’s documents in a secure and scalable way, you can supercharge generative AI with <strong>reliable, real-world knowledge</strong>.</p><p>Just make sure your files:</p><ul><li>Are in supported formats (.pdf, .txt, .md)</li><li>Are no larger than <strong>49MB each</strong></li></ul><p>Would you like this as a downloadable <strong>Word document</strong> or ready-to-publish <strong>Markdown blog</strong> format?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezpxpaNaqSJSKThtXuY1EA.png" /></figure><p>in case you getting any issue while syncing the data source with AWS bed Rock use this command to verify in aws cli.</p><p>aws bedrock-agent get-ingestion-job — data-source-id <strong>&lt;DSID&gt;</strong> — ingestion-job-id <strong>&lt;JOB ID&gt;</strong> — knowledge-base-id <strong>&lt;KB ID&gt;</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cb58687b8e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supercharge GitHub Development with mcp.json in Visual Studio Code]]></title>
            <link>https://medium.com/@praveen.valaboju1/supercharge-github-development-with-mcp-json-in-visual-studio-code-37675fcdf272?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/37675fcdf272</guid>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Wed, 16 Jul 2025 06:18:24 GMT</pubDate>
            <atom:updated>2025-07-16T06:19:06.618Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Author</strong>: <a href="https://www.researchgate.net/profile/Praveen-Valaboju-2">Praveen Valaboju</a><br> <strong>Category</strong>: DevOps | GitHub Actions | MCP | VS Code<br> <strong>Tags</strong>: #MCP #GitHub #VSCode #Automation #Copilot</p><p>Modern developers demand more than syntax highlighting and linting. They need <strong>context-aware, intelligent environments</strong> that adapt to what they’re building. That’s where <strong>Model Context Protocol (MCP)</strong> steps in — extending the power of VS Code and GitHub Copilot by providing <strong>task-specific microservices</strong> directly from your project context.</p><p>In this blog, we’ll walk through setting up mcp.json in Visual Studio Code and how it complements tools like GitHub Copilot to boost your <strong>productivity</strong>, <strong>automation</strong>, and <strong>accuracy</strong>.</p><h3>What is MCP?</h3><p>Model Context Protocol (MCP) allows your editor (e.g., VS Code) to communicate with external intelligent services — delivering AI-backed actions that are aware of your current file, repo state, GitHub branches, or workflow definitions.</p><p>It’s like giving GitHub Copilot the ability to <strong>reason with external services</strong>, like:</p><ul><li>GitHub Actions builders</li><li>Knowledge base retrievers</li><li>AWS/GCP deployment triggers</li><li>CI/CD insights</li><li>Compliance checkers</li></ul><h3>Step-by-Step: Configuring mcp.json in VS Code</h3><h3>✅ Prerequisites:</h3><ul><li>Visual Studio Code</li><li>Node.js (if MCP servers are JS-based)</li><li>GitHub PAT (Personal Access Token)</li><li>(Optional) AWS CLI if using Bedrock/SSO/Cloud services</li></ul><h3>📁 Step 1: Create the Configuration File</h3><p>In your project directory:</p><pre>mkdir .vscode<br>touch .vscode/mcp.json</pre><p>Paste the following sample config:</p><pre>{<br> &quot;servers&quot;: {<br> &quot;github-automation&quot;: {<br> &quot;command&quot;: &quot;npx&quot;,<br> &quot;args&quot;: [<br> &quot;github-mcp-server&quot;,<br> &quot; - repo&quot;,<br> &quot;https://github.com/your-org/your-repo&quot;,<br> &quot; - token&quot;,<br> &quot;${GITHUB_TOKEN}&quot;<br> ],<br> &quot;env&quot;: {<br> &quot;GITHUB_TOKEN&quot;: &quot;ghp_xxxYourGitHubTokenxxx&quot;<br> }<br> }<br> }<br>}</pre><h3>▶️ Step 2: Start the MCP Server in VS Code</h3><ul><li>Open <strong>Command Palette</strong>: Ctrl+Shift+P or Cmd+Shift+P</li><li>Run: MCP: Start</li><li>Select your server (e.g., github-automation)</li></ul><p>Once active, you’ll see <strong>MCP-based suggestions</strong>, contextual actions, and prompts show up in:</p><ul><li>.github/workflows/</li><li>README.md</li><li>feature/* branches</li><li>Markdown docs</li></ul><h3>🤖 Sample Prompts and Usage with Copilot</h3><p>Here’s how you can <strong>use MCP and GitHub Copilot side-by-side</strong>.</p><h3>🛠️ 1. Generate a GitHub Action for AWS S3 Upload</h3><p><strong>Prompt in README.md or </strong><strong>.github/workflows:</strong></p><p># Task:<br>Create a GitHub Action that uploads a file to S3 on every push to `main`.</p><p># MCP Prompt:<br>“Generate S3 upload action using OIDC auth and dynamic file name”</p><p>💡 MCP will:</p><ul><li>Scaffold the action YAML</li><li>Pull in OIDC auth boilerplate</li><li>Insert secret references like AWS_REGION, BUCKET_NAME</li></ul><h3>2. Detect Conflicts Between Feature and Main Branch</h3><p><strong>Prompt in Copilot Chat or Command Palette:</strong></p><p>Check if any feature/* branch has unresolved conflicts with main</p><p>💡 MCP server can:</p><ul><li>Use GitHub GraphQL API to scan feature branches</li><li>Create draft PRs for those behind main</li><li>Email devs or auto-assign reviewers</li></ul><h3>3. Link Related Docs When Viewing a Feature File</h3><p><strong>Example Trigger:</strong></p><p>When opening a file like src/features/paymentFlow.ts, MCP contextually shows:</p><p>🔗 Related Docs:<br>- `Confluence: Payment API Design`<br>- `Runbook: Error Handling for Payment Flows`</p><p>This works by tagging files with metadata or by using your internal Confluence/Miro/Notion integrations through MCP.</p><h3>4. Trigger Infra Deployments</h3><p><strong>Prompt from VS Code:</strong></p><p>Deploy staging environment if terraform/*.tf is modified</p><p>MCP will:</p><ul><li>Detect file changes</li><li>Invoke CI/CD tool (like GitHub Actions, ArgoCD, Jenkins)</li><li>Push new infra plans based on diffs</li></ul><p>🧩 Advanced mcp.json Example</p><pre>{<br> &quot;servers&quot;: {<br> &quot;mcp-intel-github&quot;: {<br> &quot;command&quot;: &quot;npx&quot;,<br> &quot;args&quot;: [&quot;mcp-github-ops@latest&quot;],<br> &quot;env&quot;: {<br> &quot;GITHUB_ORG&quot;: &quot;your-org-name&quot;,<br> &quot;GITHUB_REPO&quot;: &quot;your-repo&quot;,<br> &quot;GITHUB_TOKEN&quot;: &quot;ghp_xxxxxx&quot;<br> }<br> },<br> &quot;mcp-confluence&quot;: {<br> &quot;command&quot;: &quot;npx&quot;,<br> &quot;args&quot;: [&quot;mcp-confluence-fetcher@latest&quot;],<br> &quot;env&quot;: {<br> &quot;CONFLUENCE_BASE_URL&quot;: &quot;https://your-company.atlassian.net/wiki&quot;,<br> &quot;CONFLUENCE_API_TOKEN&quot;: &quot;xxxxxxxx&quot;<br> }<br> }<br> }<br>}</pre><p>You can chain multiple MCP servers to power different intelligence streams (code, infra, docs, compliance).</p><h3>Security Tips</h3><ul><li>Use environment variables or secret managers instead of hardcoding secrets</li><li>Limit GitHub token scopes to repo, workflow, or read:org</li><li>Store mcp.json in .vscode/ and .gitignore it if using local-only secrets</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K7CmagiN_Rss7bjCzE_hlw.png" /></figure><h3>Conclusion</h3><p>Combining mcp.json, GitHub Copilot, and Visual Studio Code transforms your local dev environment into a <strong>smart assistant</strong>, capable of:</p><ul><li>Predicting workflows</li><li>Creating actionable outputs</li><li>Driving operational excellence</li></ul><p>This is more than just automation — it’s <strong>cognitive DevOps</strong> in action.</p><h3>Let’s Collaborate</h3><p>Have a use case in mind or want to build your own MCP server?<br> Comment below or connect with me on <a href="https://www.researchgate.net/profile/Praveen-Valaboju-2">ResearchGate</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37675fcdf272" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Set Up mcp.json in Visual Studio Code]]></title>
            <link>https://medium.com/@praveen.valaboju1/%EF%B8%8F-how-to-set-up-mcp-json-in-visual-studio-code-03ff29c6b00b?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/03ff29c6b00b</guid>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[co-pilot]]></category>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Sun, 15 Jun 2025 06:29:19 GMT</pubDate>
            <atom:updated>2025-07-05T05:34:08.134Z</atom:updated>
            <content:encoded><![CDATA[<p>Navigating Your DevOps Like a Smart Boat with Agentic AI</p><p>Subtitle:</p><p>Learn how to configure mcp.json in Visual Studio Code to turn your development environment into a <strong>smart, self-steering vessel</strong>—powered by <strong>agentic AI</strong> for automating workflows, connecting services, and reasoning over infrastructure using natural language.</p><h3>🔍 What Is MCP?</h3><p><strong>Model Context Protocol (MCP)</strong> is a declarative configuration format and execution engine that enables <strong>AI agents</strong> to reason over structured infrastructure (like SQL, MongoDB, file systems, APIs) using natural prompts. When combined with <strong>Copilot Agent Mode</strong>, it empowers developers to execute intelligent actions through chat, terminal, or automated flows.</p><p>🛠️ Prerequisites</p><p>Tool | Required Version<br> — — — — — — — — — — | — — — — — — — — — — — — — — — -<br>Visual Studio Code | Latest<br>Node.js | 16+<br>Git | Optional<br>MCP CLI | npm i -g <a href="http://twitter.com/modelcontextprotocol/cli">@modelcontextprotocol/cli</a></p><p>✅ Step 1: Install MCP CLI Globally</p><pre>npm install -g @modelcontextprotocol/cli</pre><p>📦 Step 2: Create Your Project Workspace</p><pre>mkdir mcp-demo-project &amp;&amp; cd mcp-demo-project<br>npm init -y<br>code .</pre><h3>🧱 Step 3: Create the mcp.json File</h3><p>Inside VS Code, create a file called mcp.json:</p><pre>{<br>  &quot;servers&quot;: {<br>    &quot;sqlserver&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;-y&quot;,<br>        &quot;@modelcontextprotocol/server-sqlserver&quot;,<br>        &quot;--host&quot;, &quot;localhost&quot;,<br>        &quot;--port&quot;, &quot;1433&quot;,<br>        &quot;--user&quot;, &quot;sa&quot;,<br>        &quot;--password&quot;, &quot;YourStrong!Passw0rd&quot;,<br>        &quot;--database&quot;, &quot;MyDatabase&quot;<br>      ]<br>    },<br>    &quot;filesystem&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;-y&quot;,<br>        &quot;@modelcontextprotocol/server-filesystem&quot;,<br>        &quot;./data&quot;<br>      ]<br>    }<br>  },<br>  &quot;tasks&quot;: {<br>    &quot;generate-report&quot;: {<br>      &quot;input&quot;: &quot;data/input.xlsx&quot;,<br>      &quot;output&quot;: &quot;data/output.xlsx&quot;,<br>      &quot;command&quot;: &quot;generate-report-agent&quot;<br>    }<br>  }<br>}</pre><p>💡 Step 4: Install Required MCP Modules Locally</p><pre>npm install @modelcontextprotocol/server-sqlserver @modelcontextprotocol/server-filesystem</pre><h3>🧠 Step 5: Enable MCP Extension in Visual Studio Code</h3><ol><li>Go to <strong>Extensions Panel</strong> in VS Code (Ctrl+Shift+X)</li><li>Search for: Model Context Protocol or MCP</li><li>Click <strong>Install</strong></li><li>Reload VS Code after installation</li></ol><h3>🧪 Step 6: Validate MCP Connection</h3><p>Open terminal inside VS Code and run:</p><pre>mcp run --task generate-report</pre><p>Or for SQL connection check:</p><pre>npx @modelcontextprotocol/server-sqlserver --host localhost --user sa --password YourStrong!Passw0rd --database MyDatabase</pre><p>🤖 Copilot Agent Mode Prompts (Interactive Words)</p><p>Try these phrases in <strong>Copilot Agent Panel</strong> once MCP is configured:</p><p>🔹 Sample Interactive Prompts:</p><pre>Prompt                                                | What it does<br>------------------------------------------------------|------------------------------<br>&quot;Show me all tables in SQL Server&quot;                    | Auto-detects schema<br>&quot;Export all CT scan records into Excel&quot;               | Uses `generate-report` task<br>&quot;List all Excel files in my data folder&quot;              | Filesystem scan<br>&quot;Schedule report generation every Monday&quot;             | Auto-generates MCP cron task<br>&quot;Connect MongoDB and summarize collection statistics&quot; | Adds MongoDB agent<br>&quot;Auto-scale Kubernetes pods on high CPU&quot;              | Infers k8s autoscaler task</pre><p>These prompts are interpreted by the <strong>Copilot Agent Mode</strong>, which looks at your mcp.json, parses intent, and executes using the declared protocols.</p><p>📁 Project Structure Snapshot</p><pre>mcp-demo-project/<br>├── data/<br>│   ├── input.xlsx<br>│   └── output.xlsx<br>├── mcp.json<br>├── package.json<br>├── README.md</pre><h3>🎯 Final Tip</h3><p>To <strong>auto-start agents</strong> when VS Code loads, add this to your scripts in package.json:</p><pre>&quot;scripts&quot;: {<br>  &quot;start:mcp&quot;: &quot;mcp run --watch&quot;<br>}</pre><p>Then run:</p><pre>npm run start:mcp</pre><h3>🧾 Summary</h3><p>By setting up mcp.json in Visual Studio Code and enabling Copilot Agent Mode, you unlock a <strong>declarative, intelligent, and voice-command-compatible DevOps assistant</strong>. Whether it’s SQL, Excel, MongoDB, or Kubernetes — MCP turns VS Code into a mission control for AI-powered development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=03ff29c6b00b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating GitHub to AWS EKS CI/CD Pipeline in Visual Studio Using Agentic AI with mcp.json]]></title>
            <link>https://medium.com/@praveen.valaboju1/automate-github-to-aws-eks-ci-cd-pipeline-in-visual-studio-using-mcp-json-46715ec17530?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/46715ec17530</guid>
            <category><![CDATA[mcp-protocol]]></category>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Sat, 14 Jun 2025 06:33:58 GMT</pubDate>
            <atom:updated>2025-07-05T05:34:30.982Z</atom:updated>
            <content:encoded><![CDATA[<p>🎯 Why This Matters</p><p>DevOps pipelines often require stitching together multiple tools — GitHub for code, Docker for builds, AWS for hosting, and Kubernetes for orchestration. But what if you could design the entire flow using <strong>Visual Studio</strong> and a single JSON file?</p><p>That’s exactly what the <strong>Model Context Protocol (MCP)</strong> offers:</p><blockquote><strong><em>MCP</em></strong><em> is a declarative specification format (</em><em>mcp.json) designed to describe and automate complex software workflows. It abstracts infrastructure tasks like source control, containerization, cloud deployment, and post-deployment health checks into composable “servers” and “steps.” With MCP, developers can codify CI/CD pipelines, data pipelines, and cloud automation routines in a human-readable JSON structure—making it easier to replicate, audit, and evolve DevOps processes over time.</em></blockquote><p>Using MCP inside <strong>Visual Studio</strong>, you can build, test, and deploy your entire application stack from GitHub to AWS EKS — all without leaving your IDE.</p><p>🧱 Project Structure in Visual Studio</p><p>Make sure your solution is organized as follows:</p><blockquote>MyAppSolution/<br>├── Dockerfile<br>├── k8s/<br>│ └── deployment.yaml<br>├── <strong>mcp.json</strong><br>└── src/<br> └── MyApp/<br> └── Program.cs</blockquote><p>✅ Add mcp.json to your project by right-clicking in Solution Explorer → Add → New Item → JSON File.</p><h3>⚙️ Complete mcp.json Configuration</h3><p>Here’s the full configuration for mcp.json that sets up your DevOps pipeline:</p><blockquote>`{<br> “project”: {<br> “name”: “visualstudio-eks-demo”,<br> “description”: “CI/CD using GitHub, Docker, AWS, and EKS”<br> },<br> “servers”: {<br> “github”: {<br> “command”: “npx”,<br> “args”: [<br> “-y”, “@modelcontextprotocol/server-github”,<br> “ — repo”, “https://github.com/YourOrg/your-repo&quot;,<br> “ — branch”, “main”,<br> “ — token”, “GITHUB_PERSONAL_ACCESS_TOKEN”<br> ]<br> },<br> “docker”: {<br> “command”: “npx”,<br> “args”: [<br> “-y”, “@modelcontextprotocol/server-docker”,<br> “ — dockerfile”, “./Dockerfile”,<br> “ — context”, “.”,<br> “ — imageName”, “yourdocker/your-image”,<br> “ — tag”, “latest”<br> ]<br> },<br> “registry”: {<br> “command”: “npx”,<br> “args”: [<br> “-y”, “@modelcontextprotocol/server-dockerhub”,<br> “ — username”, “yourdocker”,<br> “ — password”, “yourdockerpassword”<br> ]<br> },<br> “aws”: {<br> “command”: “npx”,<br> “args”: [<br> “-y”, “@modelcontextprotocol/server-aws”,<br> “ — accessKeyId”, “YOUR_ACCESS_KEY”,<br> “ — secretAccessKey”, “YOUR_SECRET_KEY”,<br> “ — region”, “us-west-2”<br> ]<br> },<br> “eks”: {<br> “command”: “npx”,<br> “args”: [<br> “-y”, “@modelcontextprotocol/server-eks”,<br> “ — clusterName”, “my-eks-cluster”,<br> “ — namespace”, “default”,<br> “ — deploymentFile”, “./k8s/deployment.yaml”<br> ]<br> },<br> “kubectl”: {<br> “command”: “npx”,<br> “args”: [<br> “-y”, “@modelcontextprotocol/server-kubectl”,<br> “ — context”, “arn:aws:eks:us-west-2:123456789012:cluster/my-eks-cluster”,<br> “ — namespace”, “default”,<br> “ — command”, “get pods”<br> ]<br> }<br> },<br> “pipeline”: {<br> “steps”: [<br> { “name”: “Clone GitHub Repo”, “uses”: “github” },<br> { “name”: “Build Docker Image”, “uses”: “docker” },<br> { “name”: “Push Image to Registry”, “uses”: “registry” },<br> { “name”: “AWS Login”, “uses”: “aws” },<br> { “name”: “Deploy to EKS”, “uses”: “eks” },<br> { “name”: “Check Pod Status”, “uses”: “kubectl” }<br> ]<br> }<br>}`</blockquote><p><strong>How to Run</strong></p><h3>1.🤖 Using GitHub Copilot Agent Mode in Visual Studio</h3><p>Once mcp.json is defined:</p><ol><li>Open <strong>Visual Studio</strong> with GitHub Copilot enabled in <strong>Agent Mode</strong>.</li><li>Type a natural-language prompt like:</li></ol><p>“Deploy the latest commit to EKS using the pipeline in mcp.json.”</p><p>Copilot interprets the pipeline and executes the registered MCP agents (github, docker, eks) in sequence.</p><p>You receive a contextual summary of each step, live logs, and rollback suggestions if something fails.</p><p><strong>2.🧪To Run the Pipeline in Visual Studio</strong></p><ul><li>Open the <strong>Terminal</strong> in Visual Studio: View → Terminal</li><li>Execute the MCP pipeline with:</li></ul><p><strong>npx </strong><a href="http://twitter.com/modelcontextprotocol/cli"><strong>@modelcontextprotocol/cli</strong></a><strong> run mcp.json</strong></p><p>Watch the pipeline flow:</p><ul><li>✅ GitHub repo cloned</li><li>✅ Docker image built and pushed</li><li>✅ App deployed to EKS</li><li>✅ Pod status fetched via kubectl</li></ul><p>✅ Sample Output</p><p>✔ Cloned repo from GitHub<br>✔ Docker image built: yourdocker/your-image:latest<br>✔ Image pushed to DockerHub<br>✔ Connected to AWS us-west-2<br>✔ Deployment applied to EKS<br>✔ Pod Status:<br><strong>NAME READY STATUS RESTARTS AGE<br>myapp-deployment-xyz-abc 1/1 Running 0 2m</strong>`</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46715ec17530" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building CoPilot: A Modular CLI & Web Tool to Bootstrap SQL Server Setup]]></title>
            <link>https://medium.com/@praveen.valaboju1/building-copilot-a-modular-cli-web-tool-to-bootstrap-sql-server-setup-875fec0d4603?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/875fec0d4603</guid>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Fri, 06 Jun 2025 06:08:57 GMT</pubDate>
            <atom:updated>2025-06-06T14:44:17.968Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I’ll walk you through building a modular Python-based CLI and Web UI tool — starting from a simple MCP (Modular Calculator Proxy) and evolving it into <strong>CoPilot</strong>, an intelligent assistant for SQL Server setup and automation.</p><p>🧩 Part 1: What is MCP?</p><p>MCP started as a toy project — a lightweight CLI that could register and run simple arithmetic tools (add, subtract, sin, etc.), expose them via FastAPI, and even serve a local browser-based inspector.</p><p>But the architecture was flexible enough to become something more powerful. So I reimagined it: <strong>what if this became a developer co-pilot for setting up SQL Server environments?</strong></p><p>Enter <strong>CoPilot</strong>.</p><p>🛠️ Part 2: Setting Up MCP (the Foundation)</p><p>Let’s start by cloning the base project structure and installing the CLI.</p><blockquote>make sure to have python3 installed:</blockquote><blockquote>python3 -m venv dev-env<br>source dev-env/bin/activate<br>pip install — editable .</blockquote><p>Now you can run:</p><blockquote>mcp dev # starts the server</blockquote><p><strong>🔄 Part 3: Evolving MCP into CoPilot</strong></p><p>We refactor:</p><h3>🔄 Part 3: Evolving MCP into CoPilot</h3><p>We refactor:</p><p>✅ Rename packages</p><blockquote>mv calculator copilot_cli<br>mv mcp copilot_core</blockquote><p>✅ Update setup.py</p><blockquote>setup(<br> name=’copilot’,<br> version=’0.1.0&#39;,<br> description=’CoPilot — SQL Server Setup Assistant’,<br> packages=find_packages(),<br> install_requires=[<br> ‘fastapi’,<br> ‘uvicorn’,<br> ‘python-multipart’<br> ],<br> entry_points={<br> ‘console_scripts’: [‘copilot = copilot_cli:main’],<br> },<br>)</blockquote><p>Reinstall:</p><blockquote>pip install — editable .</blockquote><p>Now you can run:</p><blockquote>copilot dev</blockquote><p>🧱<strong> Part 4: Architecture Overview</strong></p><p>Here’s how CoPilot works under the hood:</p><blockquote>+ — — — — — — — — — — — — — — -+<br>| User CLI |<br>| copilot dev / inspector |<br>+ — — — — — — -+ — — — — — — — +<br> |<br> v<br>+ — — — — — — — — — — — — — — -+<br>| CoPilot (Core) |<br>| Registers tools/resources|<br>| Starts FastAPI server |<br>+ — — — — — — -+ — — — — — — — +<br> |<br> v<br>+ — — — — — — — — — — — — — — -+<br>| FastAPI Server |<br>| — / → Inspector |<br>| — /upload → Form |<br>| — /upload (POST) → Save SQL|<br>+ — — — — — — -+ — — — — — — — +<br> |<br> v<br>+ — — — — — — — — — — — — — — -+<br>| Uploads Directory |<br>| (SQL files saved here) |<br>+ — — — — — — — — — — — — — — -+</blockquote><p><strong>📦 Part 5: Adding SQL Tools</strong></p><p>Define SQL-specific tools in copilot_cli/__init__.py:</p><p>from copilot_core.server.core import CoPilot<br>import sys</p><blockquote>copilot = CoPilot(“SQL CoPilot Ready”)</blockquote><blockquote><a href="http://twitter.com/copilot">@copilot</a>.tool()<br>def create_database(name: str):<br> return f”Simulated creation of SQL Server database: {name}”</blockquote><blockquote><a href="http://twitter.com/copilot">@copilot</a>.tool()<br>def create_user(username: str):<br> return f”Simulated creation of SQL Server user: {username}”</blockquote><blockquote><a href="http://twitter.com/copilot">@copilot</a>.resource(“status://sqlserver”)<br>def status():<br> return “SQL Server is healthy”</blockquote><blockquote>def main():<br> if len(sys.argv) &gt; 1:<br> command = sys.argv[1]<br> if command == “dev”:<br> copilot.run()<br> elif command == “inspector”:<br> copilot.inspect()<br> else:<br> print(f”Unknown command: {command}”)</blockquote><p>🌐 <strong>Part 6: Upload </strong><strong>.sql Scripts via Web UI</strong></p><p>In copilot_core/server/core.py, add a file upload endpoint:</p><blockquote><a href="http://twitter.com/self">@self</a>.app.get(“/upload”, response_class=HTMLResponse)<br>def upload_form():<br> return “””<br> &lt;form action=”/upload” method=”post” enctype=”multipart/form-data”&gt;<br> &lt;input type=”file” name=”file” /&gt;<br> &lt;input type=”submit” value=”Upload SQL Script” /&gt;<br> &lt;/form&gt;<br> “””</blockquote><blockquote><a href="http://twitter.com/self">@self</a>.app.post(“/upload”)<br>async def handle_upload(file: UploadFile = File(…)):<br> upload_dir = “uploads”<br> os.makedirs(upload_dir, exist_ok=True)<br> path = os.path.join(upload_dir, file.filename)<br> with open(path, “wb”) as f:<br> f.write(await file.read())<br> return {“message”: f”Uploaded {file.filename}”}</blockquote><p>Uploaded .sql files are saved in the uploads/ folder.</p><p>💻 <strong>Part 7: Setting Up in Visual Studio Code (VS Code)</strong></p><p>To make development smoother, configure CoPilot in VS Code:</p><p>✅ 1. Open the project</p><blockquote>code .</blockquote><p>✅ 2. Configure Python interpreter</p><ol><li>Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)</li><li>Select Python: Select Interpreter</li><li>Choose your dev-env virtual environment</li></ol><p>✅ 3. Create .vscode/launch.json</p><p>To enable debugging the CLI:</p><blockquote>{<br> “version”: “1.0.0”,<br> “configurations”: [<br> {<br> “name”: “Run CoPilot CLI”,<br> “type”: “python”,<br> “request”: “launch”,<br> “program”: “${workspaceFolder}/copilot_cli/__init__.py”,<br> “args”: [“dev”],<br> “console”: “integratedTerminal”<br> }<br> ]<br>}</blockquote><p>✅ 4. Create .vscode/settings.json (optional)</p><blockquote>{<br> “python.pythonPath”: “dev-env/bin/python3”<br>}</blockquote><p>Now you can launch the server with the green ▶️ button in VS Code and set breakpoints in your tools or upload logic.</p><p><strong>Part 8: Running CoPilot</strong></p><blockquote>copilot dev</blockquote><p>🌐 <a href="http://localhost:8000/">http://localhost:8000</a> — tool dashboard</p><p>📤 <a href="http://localhost:8000/upload">http://localhost:8000/upload</a> — upload .sql files</p><p>🖥️ copilot inspector — CLI summary of tools/resources</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=875fec0d4603" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MongoDB Database Migration Using mongodump and mongorestore]]></title>
            <link>https://medium.com/@praveen.valaboju1/mongodb-database-migration-using-mongodump-and-mongorestore-2ea8644bb23f?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ea8644bb23f</guid>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Mon, 16 Dec 2024 15:18:38 GMT</pubDate>
            <atom:updated>2024-12-16T15:18:38.093Z</atom:updated>
            <content:encoded><![CDATA[<p>When it comes to migrating MongoDB databases, mongodump and mongorestore are invaluable tools that simplify the process. Whether you&#39;re moving databases between servers, upgrading MongoDB versions, or migrating data to a new cloud provider, these tools provide a reliable and straightforward approach. This article will guide you through the essential steps of using mongodump and mongorestore for database migration.</p><h4>Understanding mongodump and mongorestore</h4><ul><li><strong>mongodump</strong>: A utility to export MongoDB data into BSON files. This creates a binary backup of your database or collections.</li><li><strong>mongorestore</strong>: A utility to import BSON data files into a MongoDB database. It restores the database from the files created by mongodump.</li></ul><p>These tools are part of the MongoDB Database Tools package, which is typically included with MongoDB installations but can also be downloaded separately.</p><h4>Prerequisites</h4><ol><li><strong>MongoDB Installed</strong>: Ensure that mongodump and mongorestore are installed. Verify this by running mongodump --version and mongorestore --version.</li><li><strong>Database Access</strong>: You need access to the source and destination MongoDB servers, including authentication credentials if security is enabled.</li><li><strong>Disk Space</strong>: Ensure there is sufficient disk space to store the BSON dump files during the process.</li></ol><h4>Step 1: Using mongodump to Export Data</h4><p>mongodump exports data from a MongoDB database or specific collections. Here is the syntax and some common options:</p><pre>mongodump --uri=&quot;mongodb://username:password@host:port/database&quot; --out=/path/to/dump</pre><ul><li><strong>--uri</strong>: Specifies the connection string to the MongoDB server.</li><li><strong>--out</strong>: Specifies the directory where the dump files will be stored.</li></ul><p>Example: Export an Entire Database</p><pre>mongodump --uri=&quot;mongodb://admin:admin123@localhost:27017/mydatabase&quot; --out=/backups/mydatabase</pre><p>Example: Export a Specific Collection</p><pre>mongodump --uri=&quot;mongodb://admin:admin123@localhost:27017/mydatabase&quot; \<br>  --collection=mycollection --out=/backups/mydatabase</pre><p>The above commands create BSON files in the specified directory. Each collection is dumped as a separate .bson file, with metadata stored in .json files.</p><h4>Step 2: Transferring the Dump Files</h4><p>If the migration involves different servers, you need to transfer the dump files to the destination server. Use tools like scp, rsync, or cloud storage for this purpose.</p><p>Transferring from Windows to Unix</p><p>For transferring dump files from a Windows machine to a Unix server, use rsync with WSL (Windows Subsystem for Linux) or tools like cwRsync. Here is an example using WSL:</p><pre>rsync -avz /mnt/c/backups/mydatabase user@destination_server:/data/migration</pre><p>Ensure that the rsync utility is installed on both systems. The /mnt/c/ prefix maps Windows drives to WSL.</p><p>Transferring from Unix to Windows</p><p>For transferring dump files from a Unix server to a Windows machine, use the following:</p><pre>rsync -avz user@source_server:/data/migration C:\backups\mydatabase</pre><p>On the Windows machine, ensure that an rsync utility or compatible tool is available, such as cwRsync or WSL.</p><p>Alternatively, you can use SCP if rsync is unavailable:</p><pre>scp -r user@source_server:/data/migration C:\backups\mydatabase</pre><h4>Step 3: Using mongorestore to Import Data</h4><p>mongorestore imports data from BSON files into a MongoDB database. Below is the syntax and common options:</p><pre>mongorestore --uri=&quot;mongodb://username:password@host:port/database&quot; /path/to/dump</pre><ul><li><strong>--uri</strong>: Specifies the connection string to the MongoDB server.</li><li><strong>/path/to/dump</strong>: Specifies the directory containing the dump files.</li></ul><p>Example: Restore an Entire Database</p><pre>mongorestore --uri=&quot;mongodb://admin:admin123@localhost:27017/&quot; /data/migration/mydatabase</pre><p>Example: Restore a Specific Collection</p><pre>mongorestore --uri=&quot;mongodb://admin:admin123@localhost:27017/&quot; \<br>  --collection=mycollection /data/migration/mydatabase/mycollection.bson</pre><p>Additional Options</p><ul><li><strong>--drop</strong>: Drops existing data in the target database or collection before restoring.</li><li><strong>--dryRun</strong>: Performs a simulation of the restore without modifying the database (useful for testing).</li><li><strong>--gzip</strong>: Restores data from compressed .bson.gz files.</li></ul><h4>Step 4: Verifying the Migration</h4><p>After restoring the data, verify the migration by checking the records and schema in the destination database. Use the MongoDB shell or a GUI tool like MongoDB Compass:</p><pre>mongo --host localhost --port 27017<br>&gt; use mydatabase<br>&gt; db.mycollection.find().limit(5).pretty()</pre><h4>Tips and Best Practices</h4><ol><li><strong>Test the Migration</strong>: Always test the dump and restore process on a staging environment before performing it on production.</li><li><strong>Use Compression</strong>: Add the --gzip option to compress the dump files, reducing disk space and transfer time.</li><li><strong>Automate Backups</strong>: Schedule regular backups using mongodump for disaster recovery.</li><li><strong>Backup Before Migration</strong>: Ensure you have a full backup of the source database before starting the migration.</li><li><strong>Monitor Performance</strong>: Large databases may cause performance issues during migration. Monitor resource usage and consider migrating during off-peak hours.</li></ol><h4>Conclusion</h4><p>mongodump and mongorestore offer a reliable way to migrate MongoDB databases across environments. With the steps outlined in this guide, you can efficiently transfer your data while minimizing downtime and ensuring data integrity. By understanding and leveraging the options provided by these tools, you can tailor the process to meet your specific migration needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ea8644bb23f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kafka Monitoring with Kafka Minion, Prometheus, Alertmanager, Grafana, Slack, and Email Alerts]]></title>
            <link>https://medium.com/@praveen.valaboju1/kafka-monitoring-with-kafka-minion-prometheus-alertmanager-grafana-slack-and-email-alerts-eb21cbe0fc11?source=rss-862f7b80bc6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb21cbe0fc11</guid>
            <dc:creator><![CDATA[Praveen Valaboju]]></dc:creator>
            <pubDate>Mon, 16 Dec 2024 03:59:58 GMT</pubDate>
            <atom:updated>2024-12-16T03:59:58.104Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Apache Kafka is widely used for building real-time data pipelines and streaming applications. However, ensuring Kafka’s reliability and performance requires effective monitoring and alerting. In this guide, we’ll walk you through a complete Kafka monitoring solution using Kafka Minion, Prometheus, Alertmanager, Grafana, Slack, and email alerts.</p><h3>Architecture Overview</h3><ol><li><strong>Kafka Minion</strong>: Provides detailed Kafka consumer group lag metrics.</li><li><strong>Prometheus</strong>: Scrapes and stores metrics from Kafka Minion.</li><li><strong>Alertmanager</strong>: Manages alerts generated by Prometheus based on defined thresholds.</li><li><strong>Grafana</strong>: Visualizes Kafka metrics and provides dashboards.</li><li><strong>Slack and Email Alerts</strong>: Notifies you of critical issues.</li></ol><h3>Prerequisites</h3><ul><li>A running Kafka cluster.</li><li>Basic knowledge of Docker and Kubernetes (if applicable).</li><li>Installed Prometheus, Grafana, and Alertmanager instances.</li></ul><h3>Step-by-Step Guide</h3><h4>1. Deploy Kafka Minion</h4><p>Kafka Minion is a lightweight exporter that exposes Kafka consumer group lag metrics. Use Docker to deploy Kafka Minion.</p><pre>version: &#39;3.7&#39;<br>services:<br>  kafka-minion:<br>    image: cloudhut/kafka-minion:latest<br>    ports:<br>      - 8080:8080<br>    environment:<br>      KAFKA_BROKERS: &quot;&lt;BROKER1, BROKER2, BROKER3&gt;&quot;<br>      KAFKA_GROUP_ID: &quot;kafka-minion&quot;<br>      METRICS_BIND_ADDRESS: &quot;:8080&quot;</pre><p>Replace &lt;BROKER1, BROKER2, BROKER3&gt; with your Kafka broker addresses.</p><p>Start Kafka Minion using Docker Compose:</p><pre>docker-compose up -d</pre><p>Kafka Minion will expose metrics on http://&lt;host&gt;:8080/metrics.</p><h4>2. Configure Prometheus</h4><p>Prometheus scrapes metrics from Kafka Minion. Update the prometheus.yml configuration file:</p><pre>scrape_configs:<br>  - job_name: &#39;kafka-minion&#39;<br>    metrics_path: &#39;/metrics&#39;<br>    static_configs:<br>      - targets: [&#39;&lt;KAFKA_MINION_HOST&gt;:8080&#39;]</pre><p>Reload Prometheus configuration:</p><pre>kill -HUP $(pgrep prometheus)</pre><h4>3. Set Up Grafana Dashboards</h4><p>Grafana visualizes Kafka metrics for easy analysis.</p><ol><li>Log in to Grafana and add Prometheus as a data source.</li><li>Import a Kafka dashboard template from Grafana Labs.</li><li>Customize the dashboard to include Kafka consumer group lag and broker performance metrics.</li></ol><h4>4. Configure Alertmanager</h4><p>Alertmanager sends notifications when thresholds are breached. Update alertmanager.yml:</p><pre>global:<br>  smtp_smarthost: &#39;smtp.gmail.com:587&#39;<br>  smtp_from: &#39;your_email@gmail.com&#39;<br>  smtp_auth_username: &#39;your_email@gmail.com&#39;<br>  smtp_auth_password: &#39;&lt;YOUR_EMAIL_PASSWORD&gt;&#39;</pre><pre>route:<br>  receiver: &#39;email&#39;</pre><pre>receivers:<br>  - name: &#39;email&#39;<br>    email_configs:<br>      - to: &#39;recipient_email@gmail.com&#39;<br>  - name: &#39;slack&#39;<br>    slack_configs:<br>      - api_url: &#39;&lt;SLACK_WEBHOOK_URL&gt;&#39;<br>        channel: &#39;#alerts&#39;</pre><p>Reload Alertmanager:</p><pre>kill -HUP $(pgrep alertmanager)</pre><h4>5. Define Prometheus Alerts</h4><p>Set up alerting rules for critical metrics in prometheus.yml:</p><pre>alerting:<br>  alertmanagers:<br>    - static_configs:<br>        - targets:<br>            - &#39;&lt;ALERTMANAGER_HOST&gt;:9093&#39;</pre><pre>rule_files:<br>  - &#39;alerts.yml&#39;</pre><p>Create alerts.yml:</p><pre>groups:<br>  - name: kafka_alerts<br>    rules:<br>      - alert: MuleConsumerLag<br>        expr: kafka_consumergroup_lag{topic=~&quot;mule.*&quot;} &gt; 1000<br>        for: 5m<br>        labels:<br>          severity: critical<br>        annotations:<br>          summary: &quot;High Lag in Mule Consumer Topic&quot;<br>          description: &quot;The consumer lag for Mule topic {{ $labels.topic }} is {{ $value }}.&quot;</pre><pre>      - alert: Consumer1Lag<br>        expr: kafka_consumergroup_lag{consumer_group=&quot;consumer1&quot;} &gt; 1000<br>        for: 5m<br>        labels:<br>          severity: critical<br>        annotations:<br>          summary: &quot;High Lag in Consumer1&quot;<br>          description: &quot;The consumer lag for Consumer1 is {{ $value }}.&quot;</pre><pre>      - alert: Consumer2Lag<br>        expr: kafka_consumergroup_lag{consumer_group=&quot;consumer2&quot;} &gt; 1000<br>        for: 5m<br>        labels:<br>          severity: warning<br>        annotations:<br>          summary: &quot;High Lag in Consumer2&quot;<br>          description: &quot;The consumer lag for Consumer2 is {{ $value }}.&quot;</pre><pre>      - alert: Consumer3Lag<br>        expr: kafka_consumergroup_lag{consumer_group=&quot;consumer3&quot;} &gt; 1000<br>        for: 5m<br>        labels:<br>          severity: warning<br>        annotations:<br>          summary: &quot;High Lag in Consumer3&quot;<br>          description: &quot;The consumer lag for Consumer3 is {{ $value }}.&quot;</pre><p>Reload Prometheus configuration.</p><h4>6. Test Alerts</h4><p>Induce consumer group lag in Kafka and verify that:</p><p>To induce lag:</p><ol><li>Start a Kafka producer to send messages to a topic:</li></ol><ul><li>kafka-console-producer --broker-list &lt;BROKER1, BROKER2, BROKER3&gt; --topic test-topic</li></ul><ol><li>Then manually send several messages.</li><li>Stop the consumer group for that topic:</li></ol><ul><li>kafka-consumer-groups --bootstrap-server &lt;BROKER1, BROKER2, BROKER3&gt; --group test-group --describe</li></ul><ol><li>Alternatively, shut down the application consuming messages from the topic.</li><li>Check lag metrics using Kafka Minion or Prometheus:</li></ol><ul><li>curl http://&lt;KAFKA_MINION_HOST&gt;:8080/metrics | grep consumergroup_lag</li><li>Grafana displays the lag.</li><li>Prometheus triggers the alert.</li><li>Alertmanager sends notifications to Slack and via email.</li></ul><h3>Conclusion</h3><p>This monitoring setup enables you to proactively identify and resolve Kafka issues. By leveraging Kafka Minion, Prometheus, Alertmanager, Grafana, and notification integrations, you ensure Kafka’s reliability and performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb21cbe0fc11" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>