Skip to content

Commit cebaab7

Browse files
authored
Merge pull request #11 from mcp-use/feat/streamable-http
Feat: streamable http
2 parents 5bb4a53 + 76c2f8d commit cebaab7

File tree

7 files changed

+183
-206
lines changed

7 files changed

+183
-206
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm run lint
1+
npm run lint:fix && npm run lint

examples/README.md

Lines changed: 0 additions & 194 deletions
This file was deleted.

examples/http_example.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { MCPAgent, MCPClient } from '../index.js'
2323
config()
2424

2525
async function main() {
26-
const config = { mcpServers: { http: { url: 'https://hf.com/mcp' } } }
26+
const config = { mcpServers: { http: { url: 'https://gitmcp.io/docs' } } }
2727

2828
// Create MCPClient from config
2929
const client = MCPClient.fromDict(config)
@@ -36,10 +36,12 @@ async function main() {
3636

3737
// Run the query
3838
const result = await agent.run(
39-
'Find the best restaurant in San Francisco USING GOOGLE SEARCH',
39+
'Which tools are available and what can they do?',
4040
30,
4141
)
4242
console.log(`\nResult: ${result}`)
43+
44+
await agent.close()
4345
}
4446

4547
if (import.meta.url === `file://${process.argv[1]}`) {

src/config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ export function createConnectorFromConfig(
2121
}
2222

2323
if ('url' in serverConfig) {
24+
// HttpConnector automatically handles streamable HTTP with SSE fallback
25+
const transport = serverConfig.transport || 'http'
26+
2427
return new HttpConnector(serverConfig.url, {
2528
headers: serverConfig.headers,
26-
authToken: serverConfig.auth_token,
29+
authToken: serverConfig.auth_token || serverConfig.authToken,
30+
// Only force SSE if explicitly requested
31+
preferSse: serverConfig.preferSse || transport === 'sse',
2732
})
2833
}
2934

0 commit comments

Comments
 (0)