Skip to content

Add MCP server#70

Merged
codingjoe merged 20 commits intomainfrom
mcp
Apr 28, 2026
Merged

Add MCP server#70
codingjoe merged 20 commits intomainfrom
mcp

Conversation

@codingjoe
Copy link
Copy Markdown
Owner

No description provided.

@codingjoe codingjoe self-assigned this Apr 10, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 70.21277% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.12%. Comparing base (dcf9823) to head (0785eaf).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
voip/__main__.py 0.00% 14 Missing ⚠️
voip/sip/protocol.py 42.85% 12 Missing ⚠️
voip/sip/transactions.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #70      +/-   ##
==========================================
+ Coverage   61.28%   67.12%   +5.84%     
==========================================
  Files          27       28       +1     
  Lines        2291     2376      +85     
==========================================
+ Hits         1404     1595     +191     
+ Misses        887      781     -106     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codingjoe
Copy link
Copy Markdown
Owner Author

@copilot I drafted an MCP integration; please complete the work. Furthermore, make sure we offer publicly documented factory functions to establish SIP and RTP transports that mimic the mcp.run interface.

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 10, 2026

@copilot I drafted an MCP integration; please complete the work. Furthermore, make sure we offer publicly documented factory functions to establish SIP and RTP transports that mimic the mcp.run inte...

Completed in d18b3a9. Here's what was done:

  • connect_rtp(proxy_addr, stun_server=None) and connect_sip(factory, proxy_addr, *, use_tls, no_verify_tls) — public factory functions that follow the same start-and-block pattern as mcp.run. Both are fully documented in docs/mcp.md.
  • read_aor() / read_stun_server() — public helpers that read SIP_AOR / STUN_SERVER from the environment (raise ToolError when required vars are missing).
  • HangupDialog — closes the SIP transport on remote BYE, unblocking connect_sip.
  • MCPAgentCall — dataclass combining TTSMixin + TranscribeCall with MCP sampling via ctx.sample().
  • say and call tools implemented using the factory functions.
  • Separate mcp extra added to pyproject.toml (fastmcp, faster-whisper, numpy, av, pocket-tts); fastmcp removed from the ai extra.
  • voip mcp CLI command now propagates CLI args as env vars via os.environ.setdefault so the tools see SIP_AOR, STUN_SERVER, etc.

Copy link
Copy Markdown
Owner Author

@codingjoe codingjoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread voip/mcp.py Outdated
Comment thread voip/mcp.py Outdated
Comment thread docs/mcp.md Outdated
…ead_aor/read_stun_server, rewrite docs

Agent-Logs-Url: https://github.com/codingjoe/VoIP/sessions/78554363-d40c-4be1-9689-16d2380c8106

Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
Copy link
Copy Markdown
Owner Author

@codingjoe codingjoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I had a different implementation in mind. Please analize my latest commit and complete it.

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

@copilot I had a different implementation in mind. Please analize my latest commit and complete it.

Completed in 66b27e2. Here's what was done to match your design:

  • connection_poolthreading.local() holds the active SessionInitiationProtocol; both say and call tools raise RuntimeError if run() hasn't been called first.
  • MCPAgentCall(ai.AgentCall) — inherits TTS + transcription from AgentCall; overrides transcription_received (cancels pending response task) and respond (filters system messages, calls ctx.sample instead of Ollama); transcript property also filters system messages.
  • call tool — restored ctx: Context parameter and passes ctx, salutation (from initial_prompt), and optional system_prompt to MCPAgentCall.dial.
  • say tool — uses parse_uri(target, connection_pool.sip.aor) for correct tel: URI routing.
  • dialog.session — set in InviteTransaction._start_call so call can retrieve the transcript after dial() returns.
  • ollama added to mcp extra (required because MCPAgentCall inherits AgentCall which imports it).
  • CI fix — removed voip.mcp.HangupDialog reference from docs/mcp.md.
  • Teststests/test_mcp.py covers all branches of MCPAgentCall, say, call, and run.

@codingjoe codingjoe marked this pull request as ready for review April 28, 2026 12:41
Copilot AI review requested due to automatic review settings April 28, 2026 12:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a Model Context Protocol (MCP) server entrypoint to the VoIP project, exposing tools that can place calls and speak responses via MCP sampling, and wires up CLI/docs/CI support for the new feature.

Changes:

  • Introduces voip.mcp (FastMCP server) with say / call tools and a run() helper.
  • Adds a SessionInitiationProtocol.run() helper and plumbs call session storage onto Dialog.
  • Adds CLI command (voip mcp), documentation page, CI extra, and a comprehensive new test suite for MCP.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
voip/stun.py Switches STUN server default type to NetworkAddress.
voip/sip/transactions.py Stores outbound call handler on the transaction and dialog; registers RTP with the created session.
voip/sip/protocol.py Adds SessionInitiationProtocol.run() and a registration “ready” callback hook.
voip/sip/dialog.py Adds dialog.session for later access to the active RTP session handler.
voip/mcp.py New MCP server module with tools and MCP-driven agent call behavior.
voip/__main__.py Adds voip mcp command and uses Click callbacks for parsing SipURI.
tests/test_mcp.py Adds unit tests covering MCP agent behavior, tools, and run() wiring.
pyproject.toml Adds mcp extra dependencies.
mkdocs.yml / docs/mcp.md Adds MCP documentation page to site nav.
.github/workflows/ci.yml Runs tests for the new mcp extra in CI.

Comment thread voip/stun.py
Comment thread voip/sip/transactions.py Outdated
Comment thread voip/sip/protocol.py Outdated
Comment thread voip/sip/protocol.py Outdated
Comment thread voip/sip/protocol.py
Comment thread voip/__main__.py
Comment thread voip/__main__.py
codingjoe and others added 4 commits April 28, 2026 16:33
@codingjoe codingjoe merged commit e51c81c into main Apr 28, 2026
16 of 17 checks passed
@codingjoe codingjoe deleted the mcp branch April 28, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants