Skip to content

Commit a3f5268

Browse files
committed
fix: support items array for openai sdk
Former-commit-id: 4868cc2 Former-commit-id: 9b216c5b889523d772979976b9ee713766429ff1
1 parent c06e4b6 commit a3f5268

File tree

7 files changed

+101
-9
lines changed

7 files changed

+101
-9
lines changed

CHANGELOG.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
# Changelog
22

3-
## [0.2.1] - 2023-03-31
3+
## [v1.6.1] - 2025-04-01
4+
5+
### Added
6+
- OpenAI Agents SDK compatibility by adding Items property to array parameters
7+
- Test script for verifying OpenAI Agents SDK compatibility
8+
9+
### Fixed
10+
- Issue #8: Array parameters in tool definitions now include required `items` property
11+
- JSON Schema validation errors in OpenAI Agents SDK integration
12+
13+
## [v1.6.0] - 2023-03-31
414

515
### Changed
616
- Upgraded cortex dependency from v1.0.3 to v1.0.4
717

8-
## [0.2.0] - 2023-03-31
18+
## [] - 2023-03-31
919

1020
### Added
1121
- Internal logging system for improved debugging and monitoring
@@ -16,7 +26,7 @@
1626
- Restored functionality for all MCP tools
1727
- Eliminated non-JSON RPC logging in stdio mode
1828

19-
## [0.1.0] - 2023-03-25
29+
## [] - 2023-03-25
2030

2131
### Added
2232
- Initial release of DB MCP Server

README.md

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ The server follows Clean Architecture principles with these layers:
8888
- **Simultaneous Multi-Database Support**: Connect to and interact with multiple MySQL and PostgreSQL databases concurrently
8989
- **Database-Specific Tool Generation**: Auto-creates specialized tools for each connected database
9090
- **Clean Architecture**: Modular design with clear separation of concerns
91+
- **OpenAI Agents SDK Compatibility**: Full compatibility with the OpenAI Agents SDK for seamless integration with AI assistants
9192
- **Dynamic Database Tools**:
9293
- Execute SQL queries with parameters
9394
- Run data modification statements with proper error handling
@@ -568,4 +569,82 @@ If the AI assistant can't call the MCP tools:
568569
2. Verify your .cursor/mcp.json configuration is correct
569570
3. Ensure the server_name in .env matches what's in your MCP tool calls
570571
4. Restart Cursor after making configuration changes
571-
5. Check the logs in the logs/ directory for any errors
572+
5. Check the logs in the logs/ directory for any errors
573+
574+
## OpenAI Agents SDK Integration
575+
576+
The DB MCP Server fully supports OpenAI's Agents SDK, allowing you to create AI agents that can interact with databases directly.
577+
578+
### Prerequisites
579+
580+
- OpenAI account with API access
581+
- OpenAI Agents SDK installed: `pip install openai-agents`
582+
- A running DB MCP Server instance (SSE mode)
583+
584+
### Basic Integration Example
585+
586+
Here's how to integrate the DB MCP Server with an OpenAI Agent:
587+
588+
```python
589+
from openai import OpenAI
590+
from agents.agent import Agent, ModelSettings
591+
from agents.tools.mcp_server import MCPServerSse, MCPServerSseParams
592+
593+
# Connect to the MCP server
594+
db_server = MCPServerSse(
595+
params=MCPServerSseParams(
596+
url="http://localhost:9095/sse", # URL to your running DB MCP server
597+
schema={
598+
"params": {
599+
"type": "array",
600+
"items": {
601+
"type": "object",
602+
"properties": {
603+
"name": {"type": "string"},
604+
"description": {"type": "string"},
605+
"parameters": {"type": "object"}
606+
}
607+
}
608+
}
609+
}
610+
),
611+
)
612+
613+
# Create the agent with access to database tools
614+
agent = Agent(
615+
name="Database Agent",
616+
model="gpt-4o",
617+
model_settings=ModelSettings(temperature=0.1),
618+
instructions="""
619+
You are a database helper agent. You can execute SQL queries,
620+
manage database transactions, and explore schema information.
621+
""",
622+
mcp_servers=[db_server],
623+
)
624+
625+
# Now the agent can be used to interact with your databases through the OpenAI API
626+
```
627+
628+
### Testing Your Integration
629+
630+
The repository includes a test script to verify compatibility with the OpenAI Agents SDK:
631+
632+
```bash
633+
# Run the test script
634+
./test_tools/openai-agent-sdk-test/run_test.sh
635+
```
636+
637+
The script will:
638+
1. Build the server with the latest changes
639+
2. Start the server if it's not already running
640+
3. Test the connection with the OpenAI Agents SDK
641+
4. Report if the integration is working correctly
642+
643+
### Troubleshooting Agents SDK Integration
644+
645+
If you encounter issues:
646+
647+
1. Ensure the server is running in SSE mode on the expected port
648+
2. Check that your OpenAI API key is set as an environment variable
649+
3. Verify that your agent's instructions mention the database tools specifically
650+
4. Inspect the server logs for any error messages

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23
55
toolchain go1.24.1
66

77
require (
8-
github.com/FreePeak/cortex v1.0.4
8+
github.com/FreePeak/cortex v1.0.5
99
github.com/go-sql-driver/mysql v1.9.1
1010
github.com/joho/godotenv v1.5.1
1111
github.com/lib/pq v1.10.9

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
22
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
3-
github.com/FreePeak/cortex v1.0.4 h1:iIEMrCM7tvB3PfEDO8pwfKK7dbw68tUZw3vj8MuENPU=
4-
github.com/FreePeak/cortex v1.0.4/go.mod h1:hGbco4oGy1f+YxWXd+LjxtFvNSF4+ns3qwK1I1MKG4k=
3+
github.com/FreePeak/cortex v1.0.5 h1:IlAgIo1F6M7rmDVadFFxIQXdRfKPm177DUMPMfUrfhE=
4+
github.com/FreePeak/cortex v1.0.5/go.mod h1:hGbco4oGy1f+YxWXd+LjxtFvNSF4+ns3qwK1I1MKG4k=
55
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
66
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
77
github.com/go-sql-driver/mysql v1.9.1 h1:FrjNGn/BsJQjVRuSa8CBrM5BWA9BWoXXat3KrtSb/iI=

internal/delivery/mcp/tool_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func (t *QueryTool) CreateTool(name string, dbID string) interface{} {
116116
),
117117
tools.WithArray("params",
118118
tools.Description("Query parameters"),
119+
tools.Items(map[string]interface{}{"type": "string"}),
119120
),
120121
)
121122
}
@@ -189,6 +190,7 @@ func (t *ExecuteTool) CreateTool(name string, dbID string) interface{} {
189190
),
190191
tools.WithArray("params",
191192
tools.Description("Statement parameters"),
193+
tools.Items(map[string]interface{}{"type": "string"}),
192194
),
193195
)
194196
}
@@ -256,6 +258,7 @@ func (t *TransactionTool) CreateTool(name string, dbID string) interface{} {
256258
),
257259
tools.WithArray("params",
258260
tools.Description("Statement parameters"),
261+
tools.Items(map[string]interface{}{"type": "string"}),
259262
),
260263
tools.WithBoolean("readOnly",
261264
tools.Description("Whether the transaction is read-only (for begin)"),

server-linux.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a5e9fc730eb0a294a47a0247cbd31b3f83488570
1+
859b08668c2e014b51a2485ed668fde4f1f38c54

server.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
be62f163a1c5fa071646e1ffef739de32bb6d597
1+
f30913d1682b4277f6e3e9609cf83657fae228b8

0 commit comments

Comments
 (0)