Repository Public
1#!/usr/bin/env python32# =============================================================================3# SP BOUCHER | SOFTWARE & RESEARCH4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# PROJECT METADATA8# -----------------------------------------------------------------------------9# Project : API Atlas10# File : examples/xai/tools/mcp/deepwiki.py11# Module : examples12# Repository : https://git.spboucher.ai/doc-api13# Created : 2026-09-1914# Last Modified : 2026-09-1915#16# =============================================================================17# AUTHOR & PROFESSIONAL AFFILIATION18# =============================================================================19#20# Author : Simon-Pierre Boucher21# Position : Professor of Finance22# Institution : Université du Québec en Outaouais (UQO)23# Department : Département des sciences administratives24# Organization : SP Boucher25#26# Website : https://spboucher.ai27# Git : https://git.spboucher.ai28#29# =============================================================================30# OFFICIAL CONTACT DIRECTORY31# =============================================================================32#33# General : info@spboucher.ai34# Professional : contact@spboucher.ai35# Direct : simon@spboucher.ai36# Research : research@spboucher.ai37# Development : dev@spboucher.ai38# Support : support@spboucher.ai39# Security/Admin : admin@spboucher.ai40# Notifications : notifications@spboucher.ai41#42# Preferred Contact: contact@spboucher.ai43#44# =============================================================================45# COPYRIGHT & INTELLECTUAL PROPERTY46# =============================================================================47#48# Copyright (c) 202649# Simon-Pierre Boucher50#51# All rights reserved where applicable.52#53# This file is governed by the applicable project license,54# copyright notices, institutional agreements and relevant law.55#56# Unless expressly authorized by the applicable license or57# rights holder, copying, redistribution, sublicensing,58# publication and commercial exploitation are not permitted.59#60# Existing third-party rights and notices remain unaffected.61#62# =============================================================================63# CONFIDENTIALITY & SECURITY64# =============================================================================65#66# Classification : Public67# Distribution : Public repository; use is governed by the project license68# Security Contact : admin@spboucher.ai69#70# Access to this source does not independently grant permission71# to redistribute or disclose confidential materials.72#73# Do not embed credentials, private keys, access tokens,74# certificates or confidential personal information.75#76# =============================================================================77# LICENSE & MAINTENANCE78# =============================================================================79#80# License : None specified (no license file in this repository)81# Maintainer : Simon-Pierre Boucher82# Technical Contact: dev@spboucher.ai83#84# =============================================================================85# END OF SP BOUCHER SOURCE HEADER86# =============================================================================8788# STATUS: LIVE_VERIFIED — executed 2026-09-19 (exit 0 in 17.0s)89# Remote MCP tool: public DeepWiki server. mcp_call output is always returned; no approval step exists on xAI.90import os, pathlib, sys91ROOT = pathlib.Path(__file__).resolve().parents[4]; sys.path.insert(0, str(ROOT))92from scripts import live # noqa: E40293from openai import OpenAI # noqa: E4029495client = OpenAI(api_key=os.environ["XAI_API_KEY"], base_url="https://api.x.ai/v1", timeout=300)96r = client.responses.create(model="grok-4.3", store=False, max_output_tokens=4000, extra_body={"max_turns": 3}, input="Using the deepwiki tool, what does the xai-org/xai-sdk-python repo do? Max 10 words.",97 tools=[{"type": "mcp", "server_url": "https://mcp.deepwiki.com/mcp", "server_label": "deepwiki"}])98live.log_request("xai", "POST", "/v1/responses", 200, 0.02, "example xai/tools/mcp/deepwiki.py")99for o in r.output:100 if o.type == "mcp_call": print("mcp_call:", o.server_label, o.name, o.arguments[:80], "| output chars:", len(o.output or ""), "| error:", repr(o.error))101print("text:", r.output_text, "| mcp_calls:", (r.usage.model_dump().get("server_side_tool_usage_details") or {}).get("mcp_calls"))102