MCP Server Exploration
Description
# MCP A simple example of a client and server using the Connect API. ## Usage Run an MCP server: ```bash CONNECT_API_KEY="<your key>" SWAGGER_FILE="swagger.yaml" make server ``` Then run the MCP client: ```bash make client ``` Modify the chat in the main function of `app.py` to…
About
# MCP A simple example of a client and server using the Connect API. ## Usage Run an MCP server: ```bash CONNECT_API_KEY="<your key>" SWAGGER_FILE="swagger.yaml" make server ``` Then run the MCP client: ```bash make client ``` Modify the chat in the main function of `app.py` to ask different questions. ## Swagger…
Details
- Author
- mconflitti-pbc
- Downloads
- 228
- Categories
- Other
Jump to
- Example client‑server implementation using the Connect API
- Swagger/OpenAPI tool registration with Chatlas
- Expands Swagger references and transforms to operation dictionaries
- Maps OpenAPI operations to callable tools
- Includes a Shiny application demo for interactive chat
Run the server with CONNECT_API_KEY="<your key>" SWAGGER_FILE="swagger.yaml" make server. Then run the client with make client. To see the Swagger integration in action, start a local OpenAPI-compatible server using make ex-starwars and launch the Shiny application with make shiny.
MCP
A simple example of a client and server using the Connect API.
Usage
Run an MCP server:
CONNECT_API_KEY="<your key>" SWAGGER_FILE="swagger.yaml" make server
Then run the MCP client:
make client
Modify the chat in the main function of app.py to ask different questions.
Swagger Usage
The code below is a snippet of how to register Swagger tools with Chatlas.
import chatlas
import requests
from openapi_mcp.chatlas import SwaggerTool
from openapi_mcp.connect_api import map_operations_to_tools
from openapi_mcp.swagger import (
expand_all_references,
transform_swagger_to_operation_dict,
)
api_url = "127.0.0.1:8000/"
openapi_dict = requests.get(f"{api_url}/swagger.json").json()
openapi_doc = expand_all_references(openapi_dict)
operations = transform_swagger_to_operation_dict(openapi_doc)
tools = map_operations_to_tools(operations)
aws_model = os.getenv("AWS_MODEL", "us.anthropic.claude-3-5-sonnet-20241022-v2:0")
aws_region = os.getenv("AWS_REGION", "us-east-1")
chat = chatlas.ChatBedrockAnthropic(model=aws_model, aws_region=aws_region)
for operation in api_operations.values():
SwaggerTool.register_tool(
chat,
SwaggerTool(
base_url=api_url,
operation=operation,
),
)
To see this in action, run a local OpenAPI-compatible server and run the Shiny application:
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



