feat(mcp): expose sections accessor in eval bindings

Bind Worker::GetSections() as get_sections() so the TracySectionEnter /
TracySectionLeave instrumentation added to the client is reachable from
the MCP eval tool's ctx object. Returns a list of {start, end, text}
dicts with nanosecond timestamps, matching the existing list-of-dict
accessor convention. Documented in eval_guide.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EvfzHvUsDBSAwEzTfLTtA
This commit is contained in:
Alan Tse
2026-06-19 15:44:12 -07:00
parent 1706ac57ac
commit 6e4041b14d
2 changed files with 17 additions and 0 deletions

View File

@@ -214,6 +214,20 @@ PYBIND11_MODULE( TracyServerBindings, m )
return w.GetMessages().size();
} )
// --- Sections ---
.def( "get_sections", []( const Worker& w ) {
py::list result;
for( auto& s : w.GetSections() )
{
py::dict d;
d["start"] = s.start.Val();
d["end"] = s.end.Val();
d["text"] = std::string( w.GetString( s.text ) );
result.append( d );
}
return result;
} )
// --- Source locations / zones ---
.def( "get_src_loc", []( const Worker& w, int16_t id ) {
return w.GetSourceLocation( id );