Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › AI agents

Build an AI Agent for Your Software with MCP and Strands

By Freedom251 Team · · 4 min read

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To connect an AI agent to software systems you already operate, let the Strands Agents SDK run the agent loop inside your application and use the Model Context Protocol (MCP) as the standardized connection to approved data sources and tools. Your application remains responsible for identity, authorization, business rules, state, error handling, and the final decision about whether an action may run.

MCP is an integration protocol, not an agent brain or a security boundary. Strands supplies the programmable agent runtime; an MCP client discovers capabilities from an MCP server and passes selected tools to the agent. This guide shows how those pieces fit, how to implement the Python pattern documented by Strands, how to adapt it to TypeScript and web services, and which controls are required before production.

As an Amazon Associate I earn from qualifying purchases.

What the integration actually does

An MCP-based agent has three distinct responsibilities. The Strands agent interprets a user request, reasons about the available tools, and decides which tool calls to propose. The MCP client, running inside your host application, manages the protocol connection and capability negotiation. An MCP server supplies narrowly defined resources, prompts, and tools that reach your databases, APIs, files, or operational workflows.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The division matters because MCP does not implement your business logic. It standardizes how an AI application communicates with external systems; it does not automatically make an integration safe, enforce your company’s approval policy, or decide which records a user may access. Keep those decisions in your application and its existing authorization layer.

Host, client, and server

  • Host: the application that initiates the AI interaction. In this design it is your web service, worker, desktop application, or command-line process containing the Strands agent.
  • MCP client: a connector created by the host. It opens a stateful MCP session, negotiates capabilities, and exposes the server’s usable features to the host.
  • MCP server: a process or service that publishes context and capabilities. A server can expose resources (data and context), prompts (templated messages or workflows), and tools (functions the model can ask the application to execute).

MCP messages use JSON-RPC 2.0. The specification also defines optional client capabilities such as sampling, roots, and elicitation. You do not need to implement every capability to use tools, but you should know which capabilities your chosen server and client actually negotiate.

What happens during a request

  1. Your endpoint authenticates the caller and creates or retrieves the appropriate application session.
  2. The host starts, reuses, or connects to an MCP client.
  3. The client negotiates a session with the selected server and lists available tools.
  4. The host passes only approved tools to a Strands Agent.
  5. The agent calls the model provider, which may request a tool.
  6. Your application validates the proposed call, obtains any required user approval, and lets the MCP client invoke the tool.
  7. The tool result returns through MCP to the agent, which can produce a response or request another approved call.

This sequence keeps the agent loop and policy decisions in your process while using MCP for a consistent tool boundary.

Choose the SDK language and model arrangement

Strands documentation describes SDKs for Python and TypeScript. Both are intended to run in the developer’s process and can be added to an existing application rather than requiring a separate hosted control plane. Select the language that matches your service, observability stack, and deployment practices; MCP is the same protocol on either side.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Separate model choice from tool access

Strands is provider-flexible. The quickstart describes Amazon Bedrock as the default provider in its setup and documents provider swaps, while the Python README lists additional built-in providers. Provider availability, credentials, model identifiers, account requirements, and regional support change over time, so use the current provider documentation when configuring production credentials. None of those provider choices changes the MCP roles or the authorization work your application must perform.

Keep model configuration outside tool definitions. A model identifier belongs in environment-specific configuration or a secret manager, while the MCP server address, launch command, and permitted tool names belong in a separately reviewed integration configuration. This separation lets you change providers without silently widening system access.

Build the Python integration step by step

The Python README demonstrates a compact pattern: construct an MCPClient around a supported transport, enter its context, call list_tools_sync(), and pass the returned tools to Agent. The following implementation keeps the server launch details in environment variables so that the example does not assume a particular vendor or transport command.

1. Create an isolated environment and install pinned dependencies

Use a virtual environment, record the Python version used by your service, and install the current Strands packages and MCP client package shown by the release documentation. A typical starting command is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
pip install strands-agents strands-agents-tools 'mcp>=2,<3'

The current Python SDK README documents compatibility with both major mcp package versions. A fresh installation resolves to the 2.x line; use mcp<2 when you have a tested reason to remain on 1.x. Record the exact resolved versions in your lockfile and verify that your selected server supports the same major line.

2. Define the server launch configuration

For a local process, MCP commonly uses a standard-input/standard-output transport. The server’s own documentation must specify its executable, arguments, environment variables, and required credentials. Do not copy a launch command from an untrusted source into a production service.

The example below reads the command from configuration and splits arguments without embedding a fictitious server name:

import os
import shlex

server_command = os.environ['MCP_SERVER_COMMAND']
server_args = shlex.split(os.environ.get('MCP_SERVER_ARGS', ''))

For a remote service, use the transport and authentication mechanism supported by the MCP client release you installed. Do not assume that every MCP server uses stdio; the Strands README’s stdio example is a pattern, not a universal deployment requirement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Create the MCP client and expose tools to Strands

Imports can move between MCP package releases, so check the current Strands README and MCP client API before copying them verbatim. The following follows the documented structure:

import os
import shlex
from mcp import StdioServerParameters
from mcp.client.stdio import stdio_client
from strands import Agent
from strands.tools.mcp import MCPClient

server_params = StdioServerParameters(
    command=os.environ['MCP_SERVER_COMMAND'],
    args=shlex.split(os.environ.get('MCP_SERVER_ARGS', '')),
)

mcp_client = MCPClient(lambda: stdio_client(server_params))

with mcp_client:
    tools = mcp_client.list_tools_sync()
    agent = Agent(tools=tools)
    result = agent('Answer the user using only the approved connected tools.')
    print(result)

The context manager keeps the MCP session open while tools are listed and used. In a server handling many requests, create a lifecycle-managed client rather than launching a new child process for every prompt unless isolation requirements justify that cost. Close the client during application shutdown and handle startup failure explicitly.

4. Filter and describe the tool set

list_tools_sync() returns what the server advertises. Treat that list as input, not as an automatic allow-list. Select tools by stable name, attach your own policy metadata, and pass only the subset needed for the use case. A support agent might receive a read-only ticket lookup tool but not a tool that changes billing status.

Tool descriptions and annotations can help the model choose correctly, but the MCP specification says to treat them as untrusted unless they come from a trusted server. Your application should independently check the operation, arguments, target tenant, and caller permissions before invocation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Make the model call explicit in your application flow

Wrap the agent invocation in your normal request boundary. Supply a bounded prompt containing the user’s request and relevant application context, set timeouts appropriate to your endpoint, and return a controlled error when the model, MCP server, or tool fails. Do not expose raw stack traces, access tokens, or complete tool payloads to the end user.

def answer_request(user_text, user_id):
    # Authenticate and authorize before entering the agent loop.
    approved_tools = tools_for_user(user_id)
    agent = Agent(tools=approved_tools)
    return agent(user_text)

The function illustrates placement, not a complete policy implementation. Your service still needs input validation, cancellation handling, rate limits, and structured logging.

Adapt the pattern to TypeScript

Strands also documents a TypeScript SDK with MCP support. The architecture is unchanged: create an MCP client using a supported transport, discover tools, instantiate the Strands agent with that tool collection, and invoke the agent from your existing request handler. Keep the server command or endpoint in configuration, use the TypeScript SDK’s current MCP adapter names, and pin both packages together.

TypeScript is often a natural fit for Express or Next.js services. Start the MCP connection during an application lifecycle hook when a long-lived server is appropriate; otherwise create a scoped connection with a clear timeout and shutdown path. Do not share a client across tenants unless the server-side credentials and isolation model are designed for that exact sharing pattern.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Put the agent inside your existing service

The Strands quickstart describes embedding an agent in applications such as FastAPI, Express, or Next.js. Treat the agent as a component of your service, not as a replacement for the service’s request pipeline.

Request handling

  • Authenticate the caller before constructing the prompt or selecting tools.
  • Resolve tenant, role, and data-scope information from trusted server-side state, not from model text.
  • Apply request and tool-call deadlines separately. A model response can be fast while a downstream tool is unavailable, or the reverse.
  • Return a user-safe status when a dependency times out, and preserve a correlation identifier for operators.

Credentials and provider calls

The model provider is an external service in the quickstart architecture. Store its credentials in your normal secret-management system, restrict their scope, and prevent them from appearing in prompts, tool arguments, logs, or exception messages. If your organization requires regional processing or a private network path, confirm that the selected provider and deployment support those requirements before committing to the design.

Session and state decisions

Decide whether conversation history belongs in your application database, a request-scoped object, or neither. MCP sessions are stateful connections, but that does not mean they should become your product’s long-term conversation store. Persist only the history and tool results your retention policy permits, and associate every persisted record with a tenant and user identity.

Concurrency and lifecycle

A single MCP client may not be safe to use concurrently in every implementation. Read the client and server documentation, then choose one of three patterns: a process-wide client for a trusted, concurrency-safe server; a per-request client for strict isolation; or a bounded pool managed by the application. Whichever pattern you choose, test shutdown, cancellation, and server restarts rather than assuming the transport will recover automatically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apply security controls before production

The MCP specification warns that its capabilities can involve arbitrary data access and code-execution paths. It calls for user consent and control, data privacy, and tool safety, while also noting that the protocol itself cannot enforce those principles. Convert them into explicit application controls.

Use trusted servers and inspect provenance

Maintain an inventory of every MCP server, its owner, source code or distribution channel, transport, permissions, and update process. Review changes to tool definitions as you would changes to an API. A server that can read internal records or execute code deserves the same scrutiny as any privileged integration.

Enforce least privilege outside the model

  • Give each server a dedicated identity with only the data and operations required for its use case.
  • Prefer read-only credentials for lookup agents and separate identities for write operations.
  • Apply tenant and row-level authorization in the downstream service, even when the model appears to have selected a valid target.
  • Do not let a prompt, tool description, or model-generated argument grant itself additional permissions.

Require approval for consequential actions

Place a human or deterministic policy gate before irreversible, financial, privacy-sensitive, or externally visible operations. Show the user the action, target, and material arguments in a review screen. Record the decision and identity. The model may propose the action; it should not be the authority that approves it.

Validate inputs and outputs

Validate tool arguments against schemas and business rules before invocation. Limit string length, numeric ranges, file paths, query scope, and batch sizes. After a tool returns, validate the result before inserting it into a response or passing it to another tool. Treat retrieved text as untrusted content that can contain prompt-injection instructions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Log safely and test failure paths

Log the request identifier, selected tool, authorization decision, latency, and outcome without logging secrets or unnecessary personal data. Test unavailable servers, malformed results, duplicate calls, partial writes, cancellation, prompt injection, and a user attempting to access another tenant’s records. These are application tests; MCP cannot substitute for them.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Pin versions and make the build reproducible

Record the Strands SDK version, the MCP package major version, the model-provider adapter, the server version, and the transport assumptions used by your integration. The Python README’s compatibility note means that an unconstrained install can move from MCP 1.x to 2.x and change transitive dependencies. Use a lockfile, run a clean-install test in CI, and promote dependency updates through staging.

When upgrading, verify all of the following:

  • The imports for MCPClient, the transport helper, and server-parameter types still match the installed release.
  • The server and client negotiate the capabilities your agent needs.
  • Tool names, argument schemas, and error formats have not changed.
  • Authorization tests still reject an out-of-scope tenant, write operation, or oversized request.
  • Shutdown and timeout behavior remains acceptable under load.

Transport, deployment, and trust choices

Use stdio when the host intentionally launches a local or colocated server and can supervise its process. It provides a clear process boundary but requires you to manage executable paths, environment variables, restarts, and operating-system permissions. A remote transport can simplify independent deployment, but it adds network authentication, routing, certificate, and availability concerns. Choose based on isolation and operations requirements, not on an assumption that one transport is universally safer.

For a multi-tenant service, a remote server should authenticate the host and enforce tenant scope itself, while the host still performs its own authorization checks. For a local server, restrict the child process identity and filesystem access, and avoid passing broad host environment variables into it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How this approach compares with alternatives

There is no universal winner; the useful comparison is where control and responsibility live.

Approach Agent loop Tool connection Language and deployment Main trade-off
Strands plus MCP Runs in your process and is configurable Standardized MCP client/server protocol Python and TypeScript; suitable for existing services You must design authorization, lifecycle, observability, and dependency management
Direct, one-off API functions Implemented by your code or another framework Each integration uses its own interface Any language that can call the API Maximum local control, but every connector has separate schemas, error handling, and security review
Preassembled agent harness Provided by the harness Usually determined by the harness or its plugins Constrained by that product’s supported runtimes and providers Faster initial setup may reduce control over loop behavior and deployment assumptions

Choose the Strands-and-MCP combination when you need a programmable agent loop and a reusable boundary to multiple context or tool providers. Choose direct APIs when the workflow is deterministic and does not benefit from model-selected tools. In either case, keep authorization and business rules in ordinary application code.

Operational troubleshooting

The client cannot start the server

Check the executable path, argument splitting, working directory, environment variables, and operating-system permissions. Run the documented server command under the same service identity, then inspect the child-process error without exposing credentials. A mismatch between the server’s expected MCP package major version and the client’s installed version can also prevent initialization.

No tools appear

Confirm that the MCP session completed capability negotiation and that the server actually advertises tools rather than only resources or prompts. Print tool names and schemas in a development environment, verify that your filtering code did not remove them, and ensure the client remains inside its active context while listing and invoking tools.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The model ignores an available tool

Check that the tool description clearly states its purpose, required arguments, and limitations. Make the user request specific, remove unrelated tools, and verify that the selected model and Strands configuration support tool use. Do not “fix” this by granting broader credentials; tool selection and authorization are separate concerns.

A tool call fails after deployment

Compare environment variables, network reachability, credentials, server version, and timeout values between development and production. Capture a redacted request identifier and structured error category, then retry only operations that are explicitly idempotent. For writes, use an application-level idempotency key rather than blindly replaying a model-generated call.

Production readiness checklist

  • The host, MCP client, MCP server, and Strands agent responsibilities are documented.
  • Only the minimum tool set is passed to each agent and user role.
  • Server provenance, ownership, version, and update process are recorded.
  • Model and server credentials are stored outside source code and logs.
  • Write and irreversible actions require deterministic authorization or explicit user approval.
  • Tool arguments and results are validated, bounded, and tenant-scoped.
  • Timeouts, cancellation, retries, shutdown, and partial failures are tested.
  • Strands, MCP, provider adapters, and server versions are pinned and upgraded through CI.
  • Prompt-injection and data-exfiltration scenarios are part of security testing.
  • Operators can correlate a user request, model turn, tool call, authorization decision, and final outcome without seeing secrets.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

AI agentsDeveloper ToolsMCPModel Context ProtocolPythonsoftware integrationStrands Agents SDKTypeScript

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.