kensho-kfinance 2.3.0__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kensho-kfinance might be problematic. Click here for more details.
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/PKG-INFO +28 -5
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/README.md +25 -4
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kensho_kfinance.egg-info/PKG-INFO +28 -5
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kensho_kfinance.egg-info/SOURCES.txt +2 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kensho_kfinance.egg-info/requires.txt +2 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/CHANGELOG.md +3 -0
- kensho_kfinance-2.4.0/kfinance/mcp.py +101 -0
- kensho_kfinance-2.4.0/kfinance/tests/test_mcp.py +16 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/version.py +2 -2
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/pyproject.toml +2 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/.coveragerc +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/.github/workflows/ci-lint.yml +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/.github/workflows/ci-test.yml +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/.github/workflows/python-publish.yml +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/.gitignore +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/.readthedocs.yaml +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/AUTHORS.md +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/CODE_OF_CONDUCT.md +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/CONTRIBUTING.md +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/LICENSE +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/docs/build_tool_calling_documentation.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/docs/conf.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/docs/index.rst +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/docs/kfinance.rst +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/docs/requirements.txt +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/docs/templates/apidoc/package.rst_t +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/docs/templates/apidoc/toc.rst_t +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/docs/tool_calling.rst +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/example_notebooks/basic_usage.ipynb +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/example_notebooks/tool_calling/langchain/anthropic_langchain_tool_calling.ipynb +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/example_notebooks/tool_calling/langchain/google_gemini_langchain_tool_calling.ipynb +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/example_notebooks/tool_calling/langchain/openai_langchain_tool_calling.ipynb +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/example_notebooks/tool_calling/non-langchain/anthropic_tool_calling.ipynb +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/example_notebooks/tool_calling/non-langchain/google_gemini_tool_calling.ipynb +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/example_notebooks/tool_calling/non-langchain/openai_langchain_tool_calling.ipynb +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/images/colab_logo_32px.png +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/justfile +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kensho_kfinance.egg-info/dependency_links.txt +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kensho_kfinance.egg-info/top_level.txt +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/__init__.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/batch_request_handling.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/constants.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/fetch.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/kfinance.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/meta_classes.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/prompt.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/py.typed +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/pydantic_models.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/server_thread.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tests/__init__.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tests/conftest.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tests/test_batch_requests.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tests/test_client.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tests/test_example_notebook.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tests/test_fetch.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tests/test_group_objects.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tests/test_objects.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tests/test_tools.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/README.md +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/__init__.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_business_relationship_from_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_capitalization_from_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_cusip_from_ticker.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_earnings.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_earnings_call_datetimes_from_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_financial_line_item_from_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_financial_statement_from_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_history_metadata_from_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_info_from_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_isin_from_ticker.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_latest.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_latest_earnings.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_n_quarters_ago.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_next_earnings.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_prices_from_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_segments_from_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_transcript.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/prompts.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/resolve_identifier.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/shared_models.py +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/scripts/copyright_line_check.sh +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/scripts/lint.sh +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/scripts/test.sh +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/setup.cfg +0 -0
- {kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kensho-kfinance
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Python CLI for kFinance
|
|
5
5
|
Author-email: Luke Brown <luke.brown@kensho.com>, Michelle Keoy <michelle.keoy@kensho.com>, Keith Page <keith.page@kensho.com>, Matthew Rosen <matthew.rosen@kensho.com>, Nick Roshdieh <nick.roshdieh@kensho.com>
|
|
6
6
|
Project-URL: source, https://github.com/kensho-technologies/kfinance
|
|
@@ -13,6 +13,8 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
License-File: AUTHORS.md
|
|
15
15
|
Requires-Dist: cachetools<6,>=5.5
|
|
16
|
+
Requires-Dist: click<=9,>=8.2.1
|
|
17
|
+
Requires-Dist: fastmcp<3,>=2
|
|
16
18
|
Requires-Dist: langchain-core>=0.3.15
|
|
17
19
|
Requires-Dist: langchain-google-genai<3,>=2.1.5
|
|
18
20
|
Requires-Dist: numpy>=1.22.4
|
|
@@ -52,7 +54,7 @@ Any questions or suggestions can be sent to the [kFinance Maintainers](kfinance-
|
|
|
52
54
|
|
|
53
55
|
# Setup
|
|
54
56
|
|
|
55
|
-
You can install kFinance on [PyPI](https://pypi.org/project/kensho-kfinance/) via
|
|
57
|
+
You can install kFinance on [PyPI](https://pypi.org/project/kensho-kfinance/) via
|
|
56
58
|
|
|
57
59
|
`pip install kensho-kfinance`
|
|
58
60
|
|
|
@@ -64,7 +66,7 @@ Once access is obtained, get started using the [Authentication Guide](https://do
|
|
|
64
66
|
|
|
65
67
|
To get started, we provide some notebooks:
|
|
66
68
|
|
|
67
|
-
- The [LLM-ready API Basic Usage](example_notebooks%2Fbasic_usage.ipynb) notebook demonstrates how
|
|
69
|
+
- The [LLM-ready API Basic Usage](example_notebooks%2Fbasic_usage.ipynb) notebook demonstrates how
|
|
68
70
|
fetch data with the kFinance client.
|
|
69
71
|
- The [tool_calling notebooks](example_notebooks%2Ftool_calling) show how the kFinance library can
|
|
70
72
|
be used for tool calling. We provide notebooks for OpenAI (GPT), Anthropic (Claude), and Google
|
|
@@ -73,9 +75,30 @@ wrapper to simplify the integration, and as a lower level non-langchain version.
|
|
|
73
75
|
|
|
74
76
|
We also provide an [interactive notebook](example_notebooks/basic_usage.ipynb) that demonstrates some usage examples.
|
|
75
77
|
|
|
78
|
+
# MCP (Model Context Protocol)
|
|
79
|
+
|
|
80
|
+
To run the kFinance MCP server use:
|
|
81
|
+
|
|
82
|
+
`python -m kfinance.mcp`
|
|
83
|
+
|
|
84
|
+
This function initializes and starts an MCP server that exposes the kFinance tools. The server supports multiple authentication methods and transport protocols to accommodate different deployment scenarios.
|
|
85
|
+
|
|
86
|
+
The server's full signature is as follows:
|
|
87
|
+
|
|
88
|
+
`kfinance.mcp [--stdio,-s]/[--sse, ] --refresh-token <refresh-token> --client-id <client-id> --private-key <private-key>`
|
|
89
|
+
|
|
90
|
+
Authentication Methods (in order of precedence):
|
|
91
|
+
1. Refresh Token: Uses an existing refresh token for authentication. The `--refresh-token <refresh-token>` argument must be provided.
|
|
92
|
+
2. Key Pair: Uses client ID and private key for authentication. Both the `--client-id <client-id>` and `--private-key <private-key>` arguments must be provided.
|
|
93
|
+
3. Browser: Falls back to browser-based authentication flow. This occurs if no auth arguments are provided.
|
|
94
|
+
|
|
95
|
+
Transport Layers:
|
|
96
|
+
- stdio can be set by passing either `--stdio` or `-s`
|
|
97
|
+
- sse can be set by passing `--sse` or no other transport related flag
|
|
98
|
+
|
|
76
99
|
# Versioning
|
|
77
|
-
The kFinance uses semantic versioning (major, minor, patch).
|
|
78
|
-
To bump the version, add a new entry in [CHANGELOG.md](kfinance%2FCHANGELOG.md).
|
|
100
|
+
The kFinance uses semantic versioning (major, minor, patch).
|
|
101
|
+
To bump the version, add a new entry in [CHANGELOG.md](kfinance%2FCHANGELOG.md).
|
|
79
102
|
This will generate a new version of the library as part of the release process.
|
|
80
103
|
|
|
81
104
|
# License
|
|
@@ -8,7 +8,7 @@ Any questions or suggestions can be sent to the [kFinance Maintainers](kfinance-
|
|
|
8
8
|
|
|
9
9
|
# Setup
|
|
10
10
|
|
|
11
|
-
You can install kFinance on [PyPI](https://pypi.org/project/kensho-kfinance/) via
|
|
11
|
+
You can install kFinance on [PyPI](https://pypi.org/project/kensho-kfinance/) via
|
|
12
12
|
|
|
13
13
|
`pip install kensho-kfinance`
|
|
14
14
|
|
|
@@ -20,7 +20,7 @@ Once access is obtained, get started using the [Authentication Guide](https://do
|
|
|
20
20
|
|
|
21
21
|
To get started, we provide some notebooks:
|
|
22
22
|
|
|
23
|
-
- The [LLM-ready API Basic Usage](example_notebooks%2Fbasic_usage.ipynb) notebook demonstrates how
|
|
23
|
+
- The [LLM-ready API Basic Usage](example_notebooks%2Fbasic_usage.ipynb) notebook demonstrates how
|
|
24
24
|
fetch data with the kFinance client.
|
|
25
25
|
- The [tool_calling notebooks](example_notebooks%2Ftool_calling) show how the kFinance library can
|
|
26
26
|
be used for tool calling. We provide notebooks for OpenAI (GPT), Anthropic (Claude), and Google
|
|
@@ -29,9 +29,30 @@ wrapper to simplify the integration, and as a lower level non-langchain version.
|
|
|
29
29
|
|
|
30
30
|
We also provide an [interactive notebook](example_notebooks/basic_usage.ipynb) that demonstrates some usage examples.
|
|
31
31
|
|
|
32
|
+
# MCP (Model Context Protocol)
|
|
33
|
+
|
|
34
|
+
To run the kFinance MCP server use:
|
|
35
|
+
|
|
36
|
+
`python -m kfinance.mcp`
|
|
37
|
+
|
|
38
|
+
This function initializes and starts an MCP server that exposes the kFinance tools. The server supports multiple authentication methods and transport protocols to accommodate different deployment scenarios.
|
|
39
|
+
|
|
40
|
+
The server's full signature is as follows:
|
|
41
|
+
|
|
42
|
+
`kfinance.mcp [--stdio,-s]/[--sse, ] --refresh-token <refresh-token> --client-id <client-id> --private-key <private-key>`
|
|
43
|
+
|
|
44
|
+
Authentication Methods (in order of precedence):
|
|
45
|
+
1. Refresh Token: Uses an existing refresh token for authentication. The `--refresh-token <refresh-token>` argument must be provided.
|
|
46
|
+
2. Key Pair: Uses client ID and private key for authentication. Both the `--client-id <client-id>` and `--private-key <private-key>` arguments must be provided.
|
|
47
|
+
3. Browser: Falls back to browser-based authentication flow. This occurs if no auth arguments are provided.
|
|
48
|
+
|
|
49
|
+
Transport Layers:
|
|
50
|
+
- stdio can be set by passing either `--stdio` or `-s`
|
|
51
|
+
- sse can be set by passing `--sse` or no other transport related flag
|
|
52
|
+
|
|
32
53
|
# Versioning
|
|
33
|
-
The kFinance uses semantic versioning (major, minor, patch).
|
|
34
|
-
To bump the version, add a new entry in [CHANGELOG.md](kfinance%2FCHANGELOG.md).
|
|
54
|
+
The kFinance uses semantic versioning (major, minor, patch).
|
|
55
|
+
To bump the version, add a new entry in [CHANGELOG.md](kfinance%2FCHANGELOG.md).
|
|
35
56
|
This will generate a new version of the library as part of the release process.
|
|
36
57
|
|
|
37
58
|
# License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kensho-kfinance
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Python CLI for kFinance
|
|
5
5
|
Author-email: Luke Brown <luke.brown@kensho.com>, Michelle Keoy <michelle.keoy@kensho.com>, Keith Page <keith.page@kensho.com>, Matthew Rosen <matthew.rosen@kensho.com>, Nick Roshdieh <nick.roshdieh@kensho.com>
|
|
6
6
|
Project-URL: source, https://github.com/kensho-technologies/kfinance
|
|
@@ -13,6 +13,8 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
License-File: AUTHORS.md
|
|
15
15
|
Requires-Dist: cachetools<6,>=5.5
|
|
16
|
+
Requires-Dist: click<=9,>=8.2.1
|
|
17
|
+
Requires-Dist: fastmcp<3,>=2
|
|
16
18
|
Requires-Dist: langchain-core>=0.3.15
|
|
17
19
|
Requires-Dist: langchain-google-genai<3,>=2.1.5
|
|
18
20
|
Requires-Dist: numpy>=1.22.4
|
|
@@ -52,7 +54,7 @@ Any questions or suggestions can be sent to the [kFinance Maintainers](kfinance-
|
|
|
52
54
|
|
|
53
55
|
# Setup
|
|
54
56
|
|
|
55
|
-
You can install kFinance on [PyPI](https://pypi.org/project/kensho-kfinance/) via
|
|
57
|
+
You can install kFinance on [PyPI](https://pypi.org/project/kensho-kfinance/) via
|
|
56
58
|
|
|
57
59
|
`pip install kensho-kfinance`
|
|
58
60
|
|
|
@@ -64,7 +66,7 @@ Once access is obtained, get started using the [Authentication Guide](https://do
|
|
|
64
66
|
|
|
65
67
|
To get started, we provide some notebooks:
|
|
66
68
|
|
|
67
|
-
- The [LLM-ready API Basic Usage](example_notebooks%2Fbasic_usage.ipynb) notebook demonstrates how
|
|
69
|
+
- The [LLM-ready API Basic Usage](example_notebooks%2Fbasic_usage.ipynb) notebook demonstrates how
|
|
68
70
|
fetch data with the kFinance client.
|
|
69
71
|
- The [tool_calling notebooks](example_notebooks%2Ftool_calling) show how the kFinance library can
|
|
70
72
|
be used for tool calling. We provide notebooks for OpenAI (GPT), Anthropic (Claude), and Google
|
|
@@ -73,9 +75,30 @@ wrapper to simplify the integration, and as a lower level non-langchain version.
|
|
|
73
75
|
|
|
74
76
|
We also provide an [interactive notebook](example_notebooks/basic_usage.ipynb) that demonstrates some usage examples.
|
|
75
77
|
|
|
78
|
+
# MCP (Model Context Protocol)
|
|
79
|
+
|
|
80
|
+
To run the kFinance MCP server use:
|
|
81
|
+
|
|
82
|
+
`python -m kfinance.mcp`
|
|
83
|
+
|
|
84
|
+
This function initializes and starts an MCP server that exposes the kFinance tools. The server supports multiple authentication methods and transport protocols to accommodate different deployment scenarios.
|
|
85
|
+
|
|
86
|
+
The server's full signature is as follows:
|
|
87
|
+
|
|
88
|
+
`kfinance.mcp [--stdio,-s]/[--sse, ] --refresh-token <refresh-token> --client-id <client-id> --private-key <private-key>`
|
|
89
|
+
|
|
90
|
+
Authentication Methods (in order of precedence):
|
|
91
|
+
1. Refresh Token: Uses an existing refresh token for authentication. The `--refresh-token <refresh-token>` argument must be provided.
|
|
92
|
+
2. Key Pair: Uses client ID and private key for authentication. Both the `--client-id <client-id>` and `--private-key <private-key>` arguments must be provided.
|
|
93
|
+
3. Browser: Falls back to browser-based authentication flow. This occurs if no auth arguments are provided.
|
|
94
|
+
|
|
95
|
+
Transport Layers:
|
|
96
|
+
- stdio can be set by passing either `--stdio` or `-s`
|
|
97
|
+
- sse can be set by passing `--sse` or no other transport related flag
|
|
98
|
+
|
|
76
99
|
# Versioning
|
|
77
|
-
The kFinance uses semantic versioning (major, minor, patch).
|
|
78
|
-
To bump the version, add a new entry in [CHANGELOG.md](kfinance%2FCHANGELOG.md).
|
|
100
|
+
The kFinance uses semantic versioning (major, minor, patch).
|
|
101
|
+
To bump the version, add a new entry in [CHANGELOG.md](kfinance%2FCHANGELOG.md).
|
|
79
102
|
This will generate a new version of the library as part of the release process.
|
|
80
103
|
|
|
81
104
|
# License
|
|
@@ -39,6 +39,7 @@ kfinance/batch_request_handling.py
|
|
|
39
39
|
kfinance/constants.py
|
|
40
40
|
kfinance/fetch.py
|
|
41
41
|
kfinance/kfinance.py
|
|
42
|
+
kfinance/mcp.py
|
|
42
43
|
kfinance/meta_classes.py
|
|
43
44
|
kfinance/prompt.py
|
|
44
45
|
kfinance/py.typed
|
|
@@ -52,6 +53,7 @@ kfinance/tests/test_client.py
|
|
|
52
53
|
kfinance/tests/test_example_notebook.py
|
|
53
54
|
kfinance/tests/test_fetch.py
|
|
54
55
|
kfinance/tests/test_group_objects.py
|
|
56
|
+
kfinance/tests/test_mcp.py
|
|
55
57
|
kfinance/tests/test_objects.py
|
|
56
58
|
kfinance/tests/test_tools.py
|
|
57
59
|
kfinance/tool_calling/README.md
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
from textwrap import dedent
|
|
2
|
+
from typing import Literal, Optional
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
from fastmcp import FastMCP
|
|
6
|
+
from fastmcp.utilities.logging import get_logger
|
|
7
|
+
|
|
8
|
+
from kfinance.kfinance import Client
|
|
9
|
+
from kfinance.tool_calling.shared_models import KfinanceTool
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
logger = get_logger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def build_doc_string(tool: KfinanceTool) -> str:
|
|
16
|
+
"""Build a formatted documentation string for a Kfinance tool.
|
|
17
|
+
|
|
18
|
+
This function takes a KfinanceTool object and constructs a comprehensive
|
|
19
|
+
documentation string that includes the tool's description and detailed
|
|
20
|
+
information about its arguments, including default values and descriptions.
|
|
21
|
+
|
|
22
|
+
:param tool: The Kfinance tool object containing metadata about the tool's functionality, description, and argument schema.
|
|
23
|
+
:type tool: KfinanceTool
|
|
24
|
+
:return: A formatted documentation string containing for the tool description with detailed argument information.
|
|
25
|
+
:rtype: str
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
description = dedent(f"""
|
|
29
|
+
{tool.description}
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
""").strip()
|
|
33
|
+
|
|
34
|
+
for arg_name, arg_field in tool.args_schema.model_fields.items():
|
|
35
|
+
default_value_description = (
|
|
36
|
+
f"Default: {arg_field.default}. " if not arg_field.is_required() else ""
|
|
37
|
+
)
|
|
38
|
+
param_description = f"\n {arg_name}: {default_value_description}{arg_field.description}"
|
|
39
|
+
description += param_description
|
|
40
|
+
|
|
41
|
+
return description
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@click.command()
|
|
45
|
+
@click.option("--stdio/--sse", "-s/ ", default=False)
|
|
46
|
+
@click.option("--refresh-token", required=False)
|
|
47
|
+
@click.option("--client-id", required=False)
|
|
48
|
+
@click.option("--private-key", required=False)
|
|
49
|
+
def run_mcp(
|
|
50
|
+
stdio: bool,
|
|
51
|
+
refresh_token: Optional[str] = None,
|
|
52
|
+
client_id: Optional[str] = None,
|
|
53
|
+
private_key: Optional[str] = None,
|
|
54
|
+
) -> None:
|
|
55
|
+
"""Run the Kfinance MCP server with specified configuration.
|
|
56
|
+
|
|
57
|
+
This function initializes and starts an MCP server that exposes Kfinance
|
|
58
|
+
tools. The server supports multiple authentication methods and
|
|
59
|
+
transport protocols to accommodate different deployment scenarios.
|
|
60
|
+
|
|
61
|
+
Authentication Methods (in order of precedence):
|
|
62
|
+
1. Refresh Token: Uses an existing refresh token for authentication
|
|
63
|
+
2. Key Pair: Uses client ID and private key for authentication
|
|
64
|
+
3. Browser: Falls back to browser-based authentication flow
|
|
65
|
+
|
|
66
|
+
:param stdio: If True, use STDIO transport; if False, use SSE transport.
|
|
67
|
+
:type stdio: bool
|
|
68
|
+
:param refresh_token: OAuth refresh token for authentication
|
|
69
|
+
:type refresh_token: str
|
|
70
|
+
:param client_id: Client id for key-pair authentication
|
|
71
|
+
:type client_id: str
|
|
72
|
+
:param private_key: Private key for key-pair authentication.
|
|
73
|
+
:type private_key: str
|
|
74
|
+
"""
|
|
75
|
+
transport: Literal["stdio", "sse"] = "stdio" if stdio else "sse"
|
|
76
|
+
logger.info("Sever will run with %s transport", transport)
|
|
77
|
+
if refresh_token:
|
|
78
|
+
logger.info("The client will be authenticated using a refresh token")
|
|
79
|
+
kfinance_client = Client(refresh_token=refresh_token)
|
|
80
|
+
elif client_id and private_key:
|
|
81
|
+
logger.info("The client will be authenticated using a key pair")
|
|
82
|
+
kfinance_client = Client(client_id=client_id, private_key=private_key)
|
|
83
|
+
else:
|
|
84
|
+
logger.info("The client will be authenticated using a browser")
|
|
85
|
+
kfinance_client = Client()
|
|
86
|
+
|
|
87
|
+
kfinance_mcp: FastMCP = FastMCP("Kfinance")
|
|
88
|
+
for tool in kfinance_client.langchain_tools:
|
|
89
|
+
logger.info("Adding %s to server", tool.name)
|
|
90
|
+
kfinance_mcp.tool(
|
|
91
|
+
name_or_fn=getattr(tool, "_run"),
|
|
92
|
+
name=tool.name,
|
|
93
|
+
description=build_doc_string(tool),
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
logger.info("Server starting")
|
|
97
|
+
kfinance_mcp.run(transport=transport)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if __name__ == "__main__":
|
|
101
|
+
run_mcp()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from typing import Type
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from kfinance.kfinance import Client
|
|
6
|
+
from kfinance.mcp import build_doc_string
|
|
7
|
+
from kfinance.tool_calling import ALL_TOOLS
|
|
8
|
+
from kfinance.tool_calling.shared_models import KfinanceTool
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TestDocStringBuilding:
|
|
12
|
+
@pytest.mark.parametrize("tool_class", ALL_TOOLS)
|
|
13
|
+
def test_build_doc_string(self, mock_client: Client, tool_class: Type[KfinanceTool]):
|
|
14
|
+
"""This test build the docstring for each tool. A success is considered if no exception is raised"""
|
|
15
|
+
tool = tool_class(kfinance_client=mock_client)
|
|
16
|
+
build_doc_string(tool)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kensho_kfinance.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_cusip_from_ticker.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_info_from_identifier.py
RENAMED
|
File without changes
|
{kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_isin_from_ticker.py
RENAMED
|
File without changes
|
|
File without changes
|
{kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_latest_earnings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kensho_kfinance-2.3.0 → kensho_kfinance-2.4.0}/kfinance/tool_calling/get_prices_from_identifier.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|