MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / mcp_tools_from_session

Method mcp_tools_from_session

crates/opencode-session/src/prompt.rs:1548–1575  ·  view source on GitHub ↗
(session: &Session)

Source from the content-addressed store, hash-verified

1546 }
1547
1548 fn mcp_tools_from_session(session: &Session) -> Vec<ToolDefinition> {
1549 session
1550 .metadata
1551 .get("mcp_tools")
1552 .and_then(|v| v.as_array())
1553 .map(|items| {
1554 items
1555 .iter()
1556 .filter_map(|item| {
1557 let name = item.get("name").and_then(|v| v.as_str())?.to_string();
1558 let description = item
1559 .get("description")
1560 .and_then(|v| v.as_str())
1561 .map(|s| s.to_string());
1562 let parameters = item
1563 .get("parameters")
1564 .cloned()
1565 .unwrap_or_else(|| serde_json::json!({"type":"object"}));
1566 Some(ToolDefinition {
1567 name,
1568 description,
1569 parameters,
1570 })
1571 })
1572 .collect()
1573 })
1574 .unwrap_or_default()
1575 }
1576
1577 fn load_persisted_subsessions(session: &Session) -> HashMap<String, PersistedSubsession> {
1578 session

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected