Skip to main content

验证码生成工具

项目概述

这是一个基于FastMCP框架构建的验证码生成工具,提供多种类型的验证码生成功能,可以轻松集成到各种Python和TypeScript项目中,也可以作为CodeBuddy的MCP服务使用。

功能特性

  • 验证码生成
    • 生成纯数字验证码
    • 生成纯字母验证码(包含大小写)
    • 生成字母和数字混合验证码
  • TypeScript开发工具
    • 代码格式化
    • 代码分析
    • 代码模板获取
    • 代码审查提示词生成
    • 项目设置提示词生成

安装方法

从PyPI安装(推荐)

# 使用pip安装(清华源)
pip install vac-code-generator==0.1.4 -i https://pypi.tuna.tsinghua.edu.cn/simple

# 或使用官方源
pip install vac-code-generator==0.1.4

从源码安装

# 克隆代码库
git clone https://github.com/yourusername/verification-code-generator.git
cd verification-code-generator

# 安装依赖
pip install -e .

使用方法

作为MCP服务器

# 方法1:使用命令行工具
verification-code-server  # 启动标准服务器
verification-code-sse-server  # 启动SSE服务器

# 方法2:在Python代码中使用
from mcp_ts.server import create_and_run_server, create_and_run_sse_server

# 启动标准服务器
create_and_run_server(name="VerificationCodeServer", description="验证码生成服务器")

# 或启动SSE服务器
create_and_run_sse_server(name="VerificationCodeServer", description="验证码生成服务器", port=8080)

使用服务器类

# 导入服务器类
from mcp_ts.server import MCPTSServer
import asyncio

async def main():
    # 创建服务器实例
    server = MCPTSServer(name="VerificationCodeServer", description="验证码生成服务器")
    
    # 运行服务器(异步方式)
    await server.run_sse_async(host="127.0.0.1", port=8000)
    
    # 或使用标准输入输出方式
    # await server.run_async(transport="stdio")

if __name__ == "__main__":
    asyncio.run(main())

客户端示例

from mcp.client.client import Client as MCPClient
import asyncio

async def main():
    client = MCPClient(name="TSClient", description="TS客户端")
    
    try:
        # 连接到服务器
        await client.connect(transport="stdio")
        
        # 调用验证码生成工具
        code = await client.call_tool(
            "generate_mixed_verification_code",
            {"length": 8}
        )
        print(f"验证码: {code}")
        
        # 获取TypeScript模板
        template = await client.access_resource("ts-template://class")
        print(f"类模板: {template}")
        
    finally:
        await client.disconnect()

if __name__ == "__main__":
    asyncio.run(main())

与CodeBuddy集成

本项目可以作为CodeBuddy的MCP服务使用,提供验证码生成功能。

配置步骤

  1. 编辑CodeBuddy的MCP服务器配置文件:

    c:/Users/[用户名]/AppData/Roaming/CodeBuddy/User/globalStorage/tencent.planning-genie/settings/codebuddy_mcp_settings.json
    
  2. 添加以下配置:

    "验证码生成工具": {
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "python",
      "args": [
        "d:/MCP_test2/start_mcp_server_for_codebuddy.py"
      ],
      "cwd": "d:/MCP_test2"
    }
    
  3. 重启CodeBuddy或刷新MCP服务

使用方法

在CodeBuddy中,可以直接调用验证码生成工具:

请使用验证码生成工具生成一个8位混合验证码

或者:

请使用验证码生成工具生成一个6位纯数字验证码

配置文件

项目使用JSON配置文件(mcp_ts/config.json)来控制服务器行为:

{
  "server": {
    "name": "VerificationCodeServer",
    "description": "验证码生成服务器",
    "default_transport": "stdio",
    "sse": {
      "host": "127.0.0.1",
      "port": 8000
    }
  },
  "tools": {
    "verification_code": {
      "enabled": true,
      "default_length": 6
    },
    "typescript": {
      "enabled": true,
      "formatter": {
        "indent_size": 2,
        "use_tabs": false,
        "single_quotes": true
      }
    }
  },
  "resources": {
    "templates": {
      "enabled": true,
      "cache_templates": true
    }
  },
  "prompts": {
    "enabled": true,
    "default_style": "friendly"
  },
  "logging": {
    "level": "info",
    "file": "mcp_ts_server.log",
    "console": true
  }
}

开发指南

安装开发依赖

pip install -e ".[dev]"

构建并上传到PyPI

# 使用提供的脚本
python build_and_upload.py

许可证

MIT License

Metadata

Release files for vac-code-generator 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vac-code-generator 0.1.4
File Size Uploaded Provenance
vac_code_generator-0.1.4.tar.gz 12.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for vac-code-generator 0.1.4
File Interpreter ABI Platform
vac_code_generator-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / vac_code_generator-0.1.4.tar.gz

Download URL vac_code_generator-0.1.4.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
37f1b69089b0e1aa782d2be9022b8c2a4bcb203e9f31dcabe821afd31bd1e38e
BLAKE2b-256 checksum
How to use checksums
d36c79d5ac4a0fec50b6701afd4a9621aca975f389c6f1b44d612e14ff936acf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Release files / vac_code_generator-0.1.4-py3-none-any.whl

Download URL vac_code_generator-0.1.4-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5d281b645cfbce3a2d140a8cfab07a9988a9477f775d41dfdf715d34c1d9c4f
BLAKE2b-256 checksum
How to use checksums
3cc7022cec52e77e320530caf3993b232242ae7882589ecc15f6406df6b20665
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Security for vac-code-generator 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page